Spaces:
Build error
Build error
Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from transformers import MistralForCausalLM
|
| 2 |
+
from transformers import AutoTokenizer
|
| 3 |
+
|
| 4 |
+
tokenizer = AutoTokenizer.from_pretrained('mistralai/mathstral-7B-v0.1')
|
| 5 |
+
|
| 6 |
+
prompt = "What are the roots of unity?"
|
| 7 |
+
tokenized_prompts = tokenizer(prompt, return_tensors="pt")
|
| 8 |
+
|
| 9 |
+
model = MistralForCausalLM.from_pretrained('mistralai/mathstral-7B-v0.1')
|
| 10 |
+
generation = model.generate(**tokenized_prompts, max_new_tokens=512)
|
| 11 |
+
print(tokenizer.decode(generation[0]))
|
| 12 |
+
|
| 13 |
+
""" <s>What are the roots of unity?
|
| 14 |
+
|
| 15 |
+
The roots of unity are the solutions to the equation $z^n = 1$, where $n$ is a positive integer.
|
| 16 |
+
These roots are complex numbers and they form a regular $n$-gon in the complex plane.
|
| 17 |
+
|
| 18 |
+
For example, the roots of unity for $n=1$ are just $1$,
|
| 19 |
+
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}$.
|
| 20 |
+
|
| 21 |
+
The roots of unity have many interesting properties and they are used in many areas of mathematics, including number theory, algebra, and geometry.</s>
|
| 22 |
+
|
| 23 |
+
"""
|