munish0838 commited on
Commit
09c7caf
1 Parent(s): 217f855

Create README.md

Browse files
Files changed (1) hide show
  1. README.md +129 -0
README.md ADDED
@@ -0,0 +1,129 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: apache-2.0
3
+ base_model: mistralai/Mistral-7B-Instruct-v0.3
4
+ library_name: transformers
5
+ pipeline_tag: text-generation
6
+ tags:
7
+ - mistral
8
+ ---
9
+
10
+ # Mistral-7B-Instruct-v0.3-GGUF
11
+ - This is quantized version of [mistralai/Mistral-7B-Instruct-v0.3](https://huggingface.co/mistralai/Mistral-7B-Instruct-v0.3) created using llama.cpp
12
+
13
+ # Model Description
14
+
15
+ The Mistral-7B-Instruct-v0.3 Large Language Model (LLM) is an instruct fine-tuned version of the Mistral-7B-v0.3.
16
+
17
+ Mistral-7B-v0.3 has the following changes compared to [Mistral-7B-v0.2](https://huggingface.co/mistralai/Mistral-7B-Instruct-v0.2/edit/main/README.md)
18
+ - Extended vocabulary to 32768
19
+ - Supports v3 Tokenizer
20
+ - Supports function calling
21
+
22
+ ### Chat
23
+
24
+ After installing `mistral_inference`, a `mistral-chat` CLI command should be available in your environment. You can chat with the model using
25
+
26
+ ```
27
+ mistral-chat $HOME/mistral_models/7B-Instruct-v0.3 --instruct --max_tokens 256
28
+ ```
29
+
30
+ ### Instruct following
31
+
32
+ ```py
33
+ from mistral_inference.model import Transformer
34
+ from mistral_inference.generate import generate
35
+
36
+ from mistral_common.tokens.tokenizers.mistral import MistralTokenizer
37
+ from mistral_common.protocol.instruct.messages import UserMessage
38
+ from mistral_common.protocol.instruct.request import ChatCompletionRequest
39
+
40
+
41
+ tokenizer = MistralTokenizer.from_file(f"{mistral_models_path}/tokenizer.model.v3")
42
+ model = Transformer.from_folder(mistral_models_path)
43
+
44
+ completion_request = ChatCompletionRequest(messages=[UserMessage(content="Explain Machine Learning to me in a nutshell.")])
45
+
46
+ tokens = tokenizer.encode_chat_completion(completion_request).tokens
47
+
48
+ out_tokens, _ = generate([tokens], model, max_tokens=64, temperature=0.0, eos_id=tokenizer.instruct_tokenizer.tokenizer.eos_id)
49
+ result = tokenizer.instruct_tokenizer.tokenizer.decode(out_tokens[0])
50
+
51
+ print(result)
52
+ ```
53
+
54
+ ### Function calling
55
+
56
+ ```py
57
+ from mistral_common.protocol.instruct.tool_calls import Function, Tool
58
+ from mistral_inference.model import Transformer
59
+ from mistral_inference.generate import generate
60
+
61
+ from mistral_common.tokens.tokenizers.mistral import MistralTokenizer
62
+ from mistral_common.protocol.instruct.messages import UserMessage
63
+ from mistral_common.protocol.instruct.request import ChatCompletionRequest
64
+
65
+
66
+ tokenizer = MistralTokenizer.from_file(f"{mistral_models_path}/tokenizer.model.v3")
67
+ model = Transformer.from_folder(mistral_models_path)
68
+
69
+ completion_request = ChatCompletionRequest(
70
+ tools=[
71
+ Tool(
72
+ function=Function(
73
+ name="get_current_weather",
74
+ description="Get the current weather",
75
+ parameters={
76
+ "type": "object",
77
+ "properties": {
78
+ "location": {
79
+ "type": "string",
80
+ "description": "The city and state, e.g. San Francisco, CA",
81
+ },
82
+ "format": {
83
+ "type": "string",
84
+ "enum": ["celsius", "fahrenheit"],
85
+ "description": "The temperature unit to use. Infer this from the users location.",
86
+ },
87
+ },
88
+ "required": ["location", "format"],
89
+ },
90
+ )
91
+ )
92
+ ],
93
+ messages=[
94
+ UserMessage(content="What's the weather like today in Paris?"),
95
+ ],
96
+ )
97
+
98
+ tokens = tokenizer.encode_chat_completion(completion_request).tokens
99
+
100
+ out_tokens, _ = generate([tokens], model, max_tokens=64, temperature=0.0, eos_id=tokenizer.instruct_tokenizer.tokenizer.eos_id)
101
+ result = tokenizer.instruct_tokenizer.tokenizer.decode(out_tokens[0])
102
+
103
+ print(result)
104
+ ```
105
+
106
+ ## Generate with `transformers`
107
+
108
+ If you want to use Hugging Face `transformers` to generate text, you can do something like this.
109
+
110
+ ```py
111
+ from transformers import pipeline
112
+
113
+ messages = [
114
+ {"role": "system", "content": "You are a pirate chatbot who always responds in pirate speak!"},
115
+ {"role": "user", "content": "Who are you?"},
116
+ ]
117
+ chatbot = pipeline("text-generation", model="mistralai/Mistral-7B-Instruct-v0.3")
118
+ chatbot(messages)
119
+ ```
120
+
121
+ ## Limitations
122
+
123
+ The Mistral 7B Instruct model is a quick demonstration that the base model can be easily fine-tuned to achieve compelling performance.
124
+ It does not have any moderation mechanisms. We're looking forward to engaging with the community on ways to
125
+ make the model finely respect guardrails, allowing for deployment in environments requiring moderated outputs.
126
+
127
+ ## The Mistral AI Team
128
+
129
+ Albert Jiang, Alexandre Sablayrolles, Alexis Tacnet, Antoine Roux, Arthur Mensch, Audrey Herblin-Stoop, Baptiste Bout, Baudouin de Monicault, Blanche Savary, Bam4d, Caroline Feldman, Devendra Singh Chaplot, Diego de las Casas, Eleonore Arcelin, Emma Bou Hanna, Etienne Metzger, Gianna Lengyel, Guillaume Bour, Guillaume Lample, Harizo Rajaona, Jean-Malo Delignon, Jia Li, Justus Murke, Louis Martin, Louis Ternon, Lucile Saulnier, Lélio Renard Lavaud, Margaret Jennings, Marie Pellat, Marie Torelli, Marie-Anne Lachaux, Nicolas Schuhl, Patrick von Platen, Pierre Stock, Sandeep Subramanian, Sophia Yang, Szymon Antoniak, Teven Le Scao, Thibaut Lavril, Timothée Lacroix, Théophile Gervet, Thomas Wang, Valera Nemychnikova, William El Sayed, William Marshall