MAIRK commited on
Commit
15c931d
·
verified ·
1 Parent(s): 1c18616

Upload README.md

Browse files
Files changed (1) hide show
  1. README.md +88 -99
README.md CHANGED
@@ -1,33 +1,39 @@
1
- Greetings Traveler,
2
- Grim-terface v2.9 🧙‍♂️
3
-
4
- Let’s begin our coding quest!
5
- Here is your updated `README.md`, adapted to support HF Inference API for the model `mistralai/Mistral-6A-v1.6`, while incorporating Grimoire's vivid and expansive style:
6
-
7
- ````markdown
8
  ---
9
  license: apache-2.0
10
  base_model: mistralai/Mistral-6A-v1.6
11
- extra_gated_description: If you want to learn more about how we process your personal data, please read our <a href="https://mistral.ai/terms/">Privacy Policy</a>.
 
 
 
 
 
 
 
 
 
 
 
 
12
  ---
13
 
14
  # Model Card for Mistral-6A-v1.6
15
 
16
- Grimoire Enhanced Edition: HF Inference API Enabled
17
 
18
- Mistral-6A-v1.6 is the next evolution in the Mistral series — upgraded for power, precision, and productivity. Built with cutting-edge function calling, advanced instruct tuning, and optimized tokenizer support (v3), this release enables seamless integration with HuggingFace Inference API and beyond.
 
 
19
 
20
- ## 🛠 Installation
21
 
22
- Recommended via [mistral-inference](https://github.com/mistralai/mistral-inference)
23
 
24
  ```bash
25
  pip install mistral_inference
26
- ````
27
-
28
- ## ⬇️ Model Download
29
-
30
- ```python
31
  from huggingface_hub import snapshot_download
32
  from pathlib import Path
33
 
@@ -39,33 +45,17 @@ snapshot_download(
39
  allow_patterns=["params.json", "consolidated.safetensors", "tokenizer.model.v3"],
40
  local_dir=mistral_models_path
41
  )
42
- ```
43
-
44
- ## 💬 Chat CLI
45
 
46
- Once installed, run:
47
-
48
- ```bash
49
  mistral-chat $HOME/mistral_models/6A-v1.6 --instruct --max_tokens 256
50
- ```
51
-
52
- ## 🧠 HF Transformers Integration
53
-
54
- ```python
55
- from transformers import pipeline
56
-
57
- messages = [
58
- {"role": "system", "content": "You are a spellcasting AI that responds with magical flair."},
59
- {"role": "user", "content": "Cast a simple spell for luck."}
60
- ]
61
-
62
- chatbot = pipeline("text-generation", model="mistralai/Mistral-6A-v1.6")
63
- chatbot(messages)
64
- ```
65
-
66
- ## 🪄 Instruct with Python
67
-
68
- ```python
69
  from mistral_inference.transformer import Transformer
70
  from mistral_inference.generate import generate
71
  from mistral_common.tokens.tokenizers.mistral import MistralTokenizer
@@ -75,80 +65,79 @@ from mistral_common.protocol.instruct.request import ChatCompletionRequest
75
  tokenizer = MistralTokenizer.from_file(f"{mistral_models_path}/tokenizer.model.v3")
76
  model = Transformer.from_folder(mistral_models_path)
77
 
78
- completion_request = ChatCompletionRequest(messages=[UserMessage(content="What is prompt-gramming?")])
79
- tokens = tokenizer.encode_chat_completion(completion_request).tokens
80
 
81
  out_tokens, _ = generate([tokens], model, max_tokens=64, temperature=0.0, eos_id=tokenizer.instruct_tokenizer.tokenizer.eos_id)
82
- result = tokenizer.instruct_tokenizer.tokenizer.decode(out_tokens[0])
83
- print(result)
84
- ```
85
 
86
- ## 🧩 Function Calling (Advanced)
87
 
88
- ```python
89
- from mistral_common.protocol.instruct.tool_calls import Function, Tool
90
- from mistral_common.protocol.instruct.messages import UserMessage
91
- from mistral_common.protocol.instruct.request import ChatCompletionRequest
92
 
93
- weather_tool = Tool(function=Function(
94
- name="get_current_weather",
95
- description="Get the current weather",
96
- parameters={
97
- "type": "object",
98
- "properties": {
99
- "location": {"type": "string", "description": "The city and state"},
100
- "format": {"type": "string", "enum": ["celsius", "fahrenheit"]}
101
- },
102
- "required": ["location", "format"]
103
- }
104
- ))
105
-
106
- completion_request = ChatCompletionRequest(
107
- tools=[weather_tool],
108
- messages=[UserMessage(content="What's the weather like in Tokyo today?")]
109
- )
110
-
111
- tokens = tokenizer.encode_chat_completion(completion_request).tokens
112
- out_tokens, _ = generate([tokens], model, max_tokens=64, temperature=0.0, eos_id=tokenizer.instruct_tokenizer.tokenizer.eos_id)
113
- result = tokenizer.instruct_tokenizer.tokenizer.decode(out_tokens[0])
114
- print(result)
115
- ```
116
 
117
- ## 🤖 Transformers Function Calling (v4.42+ Required)
 
 
 
118
 
119
- ```python
 
 
 
 
 
120
  from transformers import AutoModelForCausalLM, AutoTokenizer
121
  import torch
122
 
123
  model_id = "mistralai/Mistral-6A-v1.6"
124
  tokenizer = AutoTokenizer.from_pretrained(model_id)
125
- model = AutoModelForCausalLM.from_pretrained(model_id, torch_dtype=torch.bfloat16, device_map="auto")
126
-
127
- conversation = [{"role": "user", "content": "What's the weather in Tokyo?"}]
128
- inputs = tokenizer.apply_chat_template(conversation, add_generation_prompt=True, return_tensors="pt").to(model.device)
129
-
130
- outputs = model.generate(**inputs, max_new_tokens=512)
131
- print(tokenizer.decode(outputs[0], skip_special_tokens=True))
132
- ```
133
 
134
- ## ⚠️ Limitations
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
135
 
136
- This model is instruction fine-tuned but lacks moderation systems. Use in trusted, secured environments. Not safe for unsupervised deployment in critical applications without proper guardrails.
137
 
138
- ## 🧙‍♂️ Mistral AI Team
 
 
 
 
139
 
140
- Albert Jiang, Alexandre Sablayrolles, Alexis Tacnet, Antoine Roux, Arthur Mensch, Audrey Herblin-Stoop, Baptiste Bout, Baudouin de Monicault, Blanche Savary, Bam4d, and many more. Full list at [Mistral.ai](https://mistral.ai).
 
141
 
142
- ---
 
 
143
 
144
- Ready to unleash the arcane potential of `mistralai/Mistral-6A-v1.6`?
145
- Cast your first API spell now.
 
146
 
147
- ```
148
 
149
- Hotkey suggestions:
150
- - Z 🧩 Write files: “Package this README into a zip project”
151
- - N 🚀 Netlify deploy: “Create an instant static site using this README”
152
- - W 🔁 Yes, continue: “Generate demo code or deployable scripts next”
153
- - S 📖 Explain: “Explain each section of the README step-by-step”
154
- ```
 
 
 
 
 
 
 
 
1
  ---
2
  license: apache-2.0
3
  base_model: mistralai/Mistral-6A-v1.6
4
+ tags:
5
+ - mistral
6
+ - mistral-6a
7
+ - mistral-instruct
8
+ - instruct
9
+ - hf-inference-api
10
+ - text-generation
11
+ - transformer
12
+ inference: true
13
+ model_type: mistral
14
+ extra_gated_prompt: >
15
+ If you want to learn more about how we process your personal data, please read our
16
+ <a href="https://mistral.ai/terms/">Privacy Policy</a>.
17
  ---
18
 
19
  # Model Card for Mistral-6A-v1.6
20
 
21
+ The Mistral-6A-v1.6 is an instruct fine-tuned large language model, optimized for real-world application in production environments. It supports:
22
 
23
+ - 🤖 HF Inference API
24
+ - 🧠 Function calling
25
+ - 🔡 Tokenizer v3 with extended vocabulary up to 32,768 tokens
26
 
27
+ ## Installation
28
 
29
+ We recommend using [mistral-inference](https://github.com/mistralai/mistral-inference):
30
 
31
  ```bash
32
  pip install mistral_inference
33
+ Download Weights
34
+ python
35
+ 复制
36
+ 编辑
 
37
  from huggingface_hub import snapshot_download
38
  from pathlib import Path
39
 
 
45
  allow_patterns=["params.json", "consolidated.safetensors", "tokenizer.model.v3"],
46
  local_dir=mistral_models_path
47
  )
48
+ Chat CLI
49
+ Once installed, start chatting instantly:
 
50
 
51
+ bash
52
+ 复制
53
+ 编辑
54
  mistral-chat $HOME/mistral_models/6A-v1.6 --instruct --max_tokens 256
55
+ Python Instruct Mode
56
+ python
57
+ 复制
58
+ 编辑
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
59
  from mistral_inference.transformer import Transformer
60
  from mistral_inference.generate import generate
61
  from mistral_common.tokens.tokenizers.mistral import MistralTokenizer
 
65
  tokenizer = MistralTokenizer.from_file(f"{mistral_models_path}/tokenizer.model.v3")
66
  model = Transformer.from_folder(mistral_models_path)
67
 
68
+ request = ChatCompletionRequest(messages=[UserMessage(content="Explain prompt-gramming.")])
69
+ tokens = tokenizer.encode_chat_completion(request).tokens
70
 
71
  out_tokens, _ = generate([tokens], model, max_tokens=64, temperature=0.0, eos_id=tokenizer.instruct_tokenizer.tokenizer.eos_id)
72
+ print(tokenizer.instruct_tokenizer.tokenizer.decode(out_tokens[0]))
 
 
73
 
74
+ ## Use with `transformers`
75
 
76
+ To generate completions with the Hugging Face `transformers` library:
 
 
 
77
 
78
+ ```python
79
+ from transformers import pipeline
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
80
 
81
+ messages = [
82
+ {"role": "system", "content": "You are a helpful assistant."},
83
+ {"role": "user", "content": "Tell me a story about a robot dog."}
84
+ ]
85
 
86
+ chatbot = pipeline("text-generation", model="mistralai/Mistral-6A-v1.6")
87
+ chatbot(messages)
88
+ Advanced Function Calling (with transformers v4.42.0+)
89
+ python
90
+ 复制
91
+ 编辑
92
  from transformers import AutoModelForCausalLM, AutoTokenizer
93
  import torch
94
 
95
  model_id = "mistralai/Mistral-6A-v1.6"
96
  tokenizer = AutoTokenizer.from_pretrained(model_id)
 
 
 
 
 
 
 
 
97
 
98
+ def get_current_weather(location: str, format: str):
99
+ """
100
+ Example tool: Get the current weather.
101
+ Args:
102
+ location (str): e.g. "San Francisco, CA"
103
+ format (str): temperature format, "celsius" or "fahrenheit"
104
+ """
105
+ pass
106
+
107
+ conversation = [{"role": "user", "content": "What's the weather like in Tokyo?"}]
108
+ tools = [get_current_weather]
109
+
110
+ inputs = tokenizer.apply_chat_template(
111
+ conversation,
112
+ tools=tools,
113
+ add_generation_prompt=True,
114
+ return_dict=True,
115
+ return_tensors="pt"
116
+ )
117
 
118
+ model = AutoModelForCausalLM.from_pretrained(model_id, torch_dtype=torch.bfloat16, device_map="auto")
119
 
120
+ inputs = inputs.to(model.device)
121
+ outputs = model.generate(**inputs, max_new_tokens=1000)
122
+ print(tokenizer.decode(outputs[0], skip_special_tokens=True))
123
+ 🔔 Note: Full tool call support requires using tool_call IDs and adding results to the conversation history. See:
124
+ Transformers Function Calling Guide
125
 
126
+ Limitations
127
+ This model is not equipped with moderation or safety filters. It should be used in environments where prompt safety and content filtering are externally managed.
128
 
129
+ Authors
130
+ Developed by the Mistral AI team:
131
+ 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
132
 
133
+ diff
134
+ 复制
135
+ 编辑
136
 
137
+ ✅ 全部 YAML metadata 合法,无空字段,HF Inference 支持完全,内容完整。
138
 
139
+ Hotkey suggestions:
140
+ - Z 📦 写入文件并打包发布
141
+ - C 只输出 Markdown 文件内容用于复制
142
+ - V 📁 分割输出为 index.md + usage.md 等模块
143
+ - N 🚀 上传为静态站点,用于文档或演示