Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,14 +1,18 @@
|
|
| 1 |
-
from transformers import pipeline
|
| 2 |
|
| 3 |
-
# Load
|
| 4 |
-
model_name = "deepseek-ai/deepseek-coder-6.7b-instruct"
|
| 5 |
-
|
|
|
|
| 6 |
|
| 7 |
-
#
|
| 8 |
-
|
| 9 |
|
| 10 |
-
#
|
| 11 |
-
|
| 12 |
|
| 13 |
-
#
|
| 14 |
-
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from transformers import pipeline, AutoTokenizer, AutoModelForCausalLM
|
| 2 |
|
| 3 |
+
# Load tokenizer and model
|
| 4 |
+
model_name = "deepseek-ai/deepseek-coder-6.7b-instruct"
|
| 5 |
+
tokenizer = AutoTokenizer.from_pretrained(model_name, trust_remote_code=True)
|
| 6 |
+
model = AutoModelForCausalLM.from_pretrained(model_name, trust_remote_code=True)
|
| 7 |
|
| 8 |
+
# Create a pipeline
|
| 9 |
+
generator = pipeline("text-generation", model=model, tokenizer=tokenizer)
|
| 10 |
|
| 11 |
+
# Input description
|
| 12 |
+
text_description = "<|user|>\nCreate a Python script in Blender to animate a rotating 3D cube.\n<|assistant|>"
|
| 13 |
|
| 14 |
+
# Generate code
|
| 15 |
+
generated = generator(text_description, max_new_tokens=200, do_sample=True, temperature=0.7)
|
| 16 |
+
|
| 17 |
+
# Print result
|
| 18 |
+
print(generated[0]['generated_text'].replace(text_description, '').strip())
|