Upload requirements.txt with huggingface_hub
Browse files- requirements.txt +4 -36
requirements.txt
CHANGED
|
@@ -1,36 +1,4 @@
|
|
| 1 |
-
|
| 2 |
-
|
| 3 |
-
|
| 4 |
-
|
| 5 |
-
def __init__(self, path=""):
|
| 6 |
-
print(f"Loading model from: {path}")
|
| 7 |
-
|
| 8 |
-
# Use the exact same approach as your local inference script
|
| 9 |
-
self.tokenizer = AutoTokenizer.from_pretrained(path)
|
| 10 |
-
self.model = AutoModelForSeq2SeqLM.from_pretrained(
|
| 11 |
-
path,
|
| 12 |
-
torch_dtype=torch.bfloat16
|
| 13 |
-
)
|
| 14 |
-
|
| 15 |
-
print("Model loaded successfully")
|
| 16 |
-
|
| 17 |
-
def __call__(self, data):
|
| 18 |
-
inputs = data.pop("inputs", data)
|
| 19 |
-
messages = [{"role": "user", "content": inputs}]
|
| 20 |
-
|
| 21 |
-
input_ids = self.tokenizer.apply_chat_template(
|
| 22 |
-
messages,
|
| 23 |
-
add_generation_prompt=True,
|
| 24 |
-
return_tensors="pt"
|
| 25 |
-
)
|
| 26 |
-
|
| 27 |
-
outputs = self.model.generate(
|
| 28 |
-
input_ids,
|
| 29 |
-
max_new_tokens=1024,
|
| 30 |
-
temperature=0.1,
|
| 31 |
-
do_sample=True
|
| 32 |
-
)
|
| 33 |
-
|
| 34 |
-
return {
|
| 35 |
-
"generated_text": self.tokenizer.decode(outputs[0], skip_special_tokens=True)
|
| 36 |
-
}
|
|
|
|
| 1 |
+
torch>=2.6.0
|
| 2 |
+
git+https://github.com/huggingface/transformers.git
|
| 3 |
+
sentencepiece>=0.1.99
|
| 4 |
+
accelerate>=0.21.0
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|