Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
@@ -1,9 +1,9 @@
|
|
1 |
from fastapi import FastAPI
|
2 |
-
from transformers import
|
3 |
import uvicorn
|
4 |
|
5 |
tokenizer = AutoTokenizer.from_pretrained("Qwen/Qwen3-0.6B")
|
6 |
-
model =
|
7 |
|
8 |
app = FastAPI()
|
9 |
|
@@ -14,11 +14,7 @@ def greet_json():
|
|
14 |
@app.get("/message")
|
15 |
async def message(input: str):
|
16 |
inputs = tokenizer(input, return_tensors="pt", padding=True, truncation=True)
|
17 |
-
output = model.generate(
|
18 |
-
input_ids=inputs["input_ids"],
|
19 |
-
attention_mask=inputs["attention_mask"],
|
20 |
-
temperature=0.3
|
21 |
-
)
|
22 |
return tokenizer.decode(output[0], skip_special_tokens=True)
|
23 |
|
24 |
if __name__ == "__main__":
|
|
|
1 |
from fastapi import FastAPI
|
2 |
+
from transformers import AutoModelForCausalLM, AutoTokenizer
|
3 |
import uvicorn
|
4 |
|
5 |
tokenizer = AutoTokenizer.from_pretrained("Qwen/Qwen3-0.6B")
|
6 |
+
model = AutoModelForCausalLM.from_pretrained("Qwen/Qwen3-0.6B")
|
7 |
|
8 |
app = FastAPI()
|
9 |
|
|
|
14 |
@app.get("/message")
|
15 |
async def message(input: str):
|
16 |
inputs = tokenizer(input, return_tensors="pt", padding=True, truncation=True)
|
17 |
+
output = model.generate(**inputs, max_length=50, temperature=0.3)
|
|
|
|
|
|
|
|
|
18 |
return tokenizer.decode(output[0], skip_special_tokens=True)
|
19 |
|
20 |
if __name__ == "__main__":
|