Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -4,11 +4,12 @@ import torch
|
|
| 4 |
|
| 5 |
model_id = "moonshotai/Kimi-K2-Instruct"
|
| 6 |
|
| 7 |
-
tokenizer = AutoTokenizer.from_pretrained(model_id)
|
| 8 |
model = AutoModelForCausalLM.from_pretrained(
|
| 9 |
model_id,
|
| 10 |
torch_dtype=torch.float16,
|
| 11 |
-
device_map="auto"
|
|
|
|
| 12 |
)
|
| 13 |
|
| 14 |
def chat(prompt):
|
|
@@ -29,4 +30,4 @@ def chat(prompt):
|
|
| 29 |
response = tokenizer.decode(outputs[0][input_ids.shape[-1]:], skip_special_tokens=True)
|
| 30 |
return response.strip()
|
| 31 |
|
| 32 |
-
gr.Interface(fn=chat, inputs=gr.Textbox(lines=5, label="Prompt"), outputs="text").launch()
|
|
|
|
| 4 |
|
| 5 |
model_id = "moonshotai/Kimi-K2-Instruct"
|
| 6 |
|
| 7 |
+
tokenizer = AutoTokenizer.from_pretrained(model_id, trust_remote_code=True)
|
| 8 |
model = AutoModelForCausalLM.from_pretrained(
|
| 9 |
model_id,
|
| 10 |
torch_dtype=torch.float16,
|
| 11 |
+
device_map="auto",
|
| 12 |
+
trust_remote_code=True
|
| 13 |
)
|
| 14 |
|
| 15 |
def chat(prompt):
|
|
|
|
| 30 |
response = tokenizer.decode(outputs[0][input_ids.shape[-1]:], skip_special_tokens=True)
|
| 31 |
return response.strip()
|
| 32 |
|
| 33 |
+
gr.Interface(fn=chat, inputs=gr.Textbox(lines=5, label="Prompt"), outputs="text").launch()
|