Update README.md
Browse filesadd a short example of transformers lib usage
README.md
CHANGED
|
@@ -42,6 +42,33 @@ You can then start chatting with the model, *e.g.* prompt it with something like
|
|
| 42 |
|
| 43 |
*"Albert likes to surf every week. Each surfing session lasts for 4 hours and costs $20 per hour. How much would Albert spend in 5 weeks?"*
|
| 44 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 45 |
## Evaluation
|
| 46 |
We evaluate Mathstral 7B and open-weight models of the similar size on industry-standard benchmarks.
|
| 47 |
| Benchmarks | MATH | GSM8K (8-shot) | Odyssey Math maj@16 | GRE Math maj@16 | AMC 2023 maj@16 | AIME 2024 maj@16
|
|
|
|
| 42 |
|
| 43 |
*"Albert likes to surf every week. Each surfing session lasts for 4 hours and costs $20 per hour. How much would Albert spend in 5 weeks?"*
|
| 44 |
|
| 45 |
+
### Usage in `transformers`
|
| 46 |
+
|
| 47 |
+
To use this model within the `transformers` library, install the latest release with `pip install --upgrade transformers` and run, for instance:
|
| 48 |
+
|
| 49 |
+
```py
|
| 50 |
+
from transformers import MistralForCausalLM
|
| 51 |
+
from transformers import AutoTokenizer
|
| 52 |
+
|
| 53 |
+
tokenizer = AutoTokenizer.from_pretrained('mistralai/mathstral-7B-v0.1')
|
| 54 |
+
|
| 55 |
+
prompt = "What are the roots of unity?"
|
| 56 |
+
tokenized_prompts = tokenizer(prompt, return_tensors="pt")
|
| 57 |
+
|
| 58 |
+
model = MistralForCausalLM.from_pretrained('mistralai/mathstral-7B-v0.1')
|
| 59 |
+
generation = model.generate(**tokenized_prompts, max_new_tokens=512)
|
| 60 |
+
print(tokenizer.decode(generation[0]))
|
| 61 |
+
>>> """<s>What are the roots of unity?
|
| 62 |
+
|
| 63 |
+
The roots of unity are the solutions to the equation $z^n = 1$, where $n$ is a positive integer.
|
| 64 |
+
These roots are complex numbers and they form a regular $n$-gon in the complex plane.
|
| 65 |
+
|
| 66 |
+
For example, the roots of unity for $n=1$ are just $1$,
|
| 67 |
+
and for $n=2$ they are $1$ and $-1$. For $n=3$, they are $1$, $\\frac{-1+\\sqrt{3}i}{2}$, and $\\frac{-1-\\sqrt{3}i}{2}$.
|
| 68 |
+
|
| 69 |
+
The roots of unity have many interesting properties and they are used in many areas of mathematics, including number theory, algebra, and geometry.</s>"""
|
| 70 |
+
```
|
| 71 |
+
|
| 72 |
## Evaluation
|
| 73 |
We evaluate Mathstral 7B and open-weight models of the similar size on industry-standard benchmarks.
|
| 74 |
| Benchmarks | MATH | GSM8K (8-shot) | Odyssey Math maj@16 | GRE Math maj@16 | AMC 2023 maj@16 | AIME 2024 maj@16
|