Spaces:
Sleeping
Sleeping
req.txt
Browse files- app.py +6 -3
- requirements.txt +2 -1
app.py
CHANGED
|
@@ -6,8 +6,7 @@ import json
|
|
| 6 |
"""
|
| 7 |
For more information on `huggingface_hub` Inference API support, please check the docs: https://huggingface.co/docs/huggingface_hub/v0.22.2/en/guides/inference
|
| 8 |
"""
|
| 9 |
-
|
| 10 |
-
tokenizer = AutoTokenizer.from_pretrained("KishoreK/ActionGemma-9B")
|
| 11 |
|
| 12 |
def respond(
|
| 13 |
message,
|
|
@@ -87,7 +86,11 @@ If the given question lacks the parameters required by the function, also point
|
|
| 87 |
"content": json.dumps(convert_to_xlam_tool(tools))
|
| 88 |
}]
|
| 89 |
|
| 90 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 91 |
|
| 92 |
"""
|
| 93 |
For information on how to customize the ChatInterface, peruse the gradio docs: https://www.gradio.app/docs/chatinterface
|
|
|
|
| 6 |
"""
|
| 7 |
For more information on `huggingface_hub` Inference API support, please check the docs: https://huggingface.co/docs/huggingface_hub/v0.22.2/en/guides/inference
|
| 8 |
"""
|
| 9 |
+
|
|
|
|
| 10 |
|
| 11 |
def respond(
|
| 12 |
message,
|
|
|
|
| 86 |
"content": json.dumps(convert_to_xlam_tool(tools))
|
| 87 |
}]
|
| 88 |
|
| 89 |
+
model = AutoModelForCausalLM.from_pretrained("KishoreK/ActionGemma-9B", load_in_4bit=True, device_map="auto", use_cache=True,low_cpu_mem_usage=True )
|
| 90 |
+
tokenizer = AutoTokenizer.from_pretrained("KishoreK/ActionGemma-9B")
|
| 91 |
+
inputs = tokenizer.apply_chat_template(messages, add_generation_prompt=True)
|
| 92 |
+
outputs = model.generate(inputs, max_new_tokens=512, do_sample=False, num_return_sequences=1, eos_token_id=tokenizer.eos_token_id)
|
| 93 |
+
return tokenizer.decode(outputs[0][len(inputs[0]):], skip_special_tokens=True)
|
| 94 |
|
| 95 |
"""
|
| 96 |
For information on how to customize the ChatInterface, peruse the gradio docs: https://www.gradio.app/docs/chatinterface
|
requirements.txt
CHANGED
|
@@ -1,3 +1,4 @@
|
|
| 1 |
huggingface_hub==0.23.2
|
| 2 |
transformers==4.43.3
|
| 3 |
-
torch
|
|
|
|
|
|
| 1 |
huggingface_hub==0.23.2
|
| 2 |
transformers==4.43.3
|
| 3 |
+
torch
|
| 4 |
+
accelerate
|