Spaces:
Runtime error
Runtime error
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
from transformers import AutoModelForCausalLM, AutoTokenizer
|
3 |
+
|
4 |
+
model_name = 'deepseek-ai/deepseek-coder-33b-instruct'
|
5 |
+
|
6 |
+
tokenizer = AutoTokenizer.from_pretrained(model_name)
|
7 |
+
model = AutoModelForCausalLM.from_pretrained(model_name)
|
8 |
+
|
9 |
+
|
10 |
+
input_ids = tokenizer.encode(input_text, return_tensors="pt")
|
11 |
+
|
12 |
+
kwargs = {
|
13 |
+
"max_length": 500,
|
14 |
+
"num_return_sequences": 1,
|
15 |
+
"temperature": 0.7,
|
16 |
+
"top_k": 50
|
17 |
+
}
|
18 |
+
|
19 |
+
# Generate text
|
20 |
+
output_ids = model.generate(input_ids, **kwargs)
|
21 |
+
|
22 |
+
# Decode and print the output
|
23 |
+
output_text = tokenizer.decode(output_ids[0], skip_special_tokens=True)
|
24 |
+
print(output_text)
|