Instructions to use aidando73/llama-3.3-70b-instruct-code-agent-fine-tune-v1 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use aidando73/llama-3.3-70b-instruct-code-agent-fine-tune-v1 with Transformers:
# Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("aidando73/llama-3.3-70b-instruct-code-agent-fine-tune-v1", dtype="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- Unsloth Studio
How to use aidando73/llama-3.3-70b-instruct-code-agent-fine-tune-v1 with Unsloth Studio:
Install Unsloth Studio (macOS, Linux, WSL)
curl -fsSL https://unsloth.ai/install.sh | sh # Run unsloth studio unsloth studio -H 0.0.0.0 -p 8888 # Then open http://localhost:8888 in your browser # Search for aidando73/llama-3.3-70b-instruct-code-agent-fine-tune-v1 to start chatting
Install Unsloth Studio (Windows)
irm https://unsloth.ai/install.ps1 | iex # Run unsloth studio unsloth studio -H 0.0.0.0 -p 8888 # Then open http://localhost:8888 in your browser # Search for aidando73/llama-3.3-70b-instruct-code-agent-fine-tune-v1 to start chatting
Using HuggingFace Spaces for Unsloth
# No setup required # Open https://huggingface.co/spaces/unsloth/studio in your browser # Search for aidando73/llama-3.3-70b-instruct-code-agent-fine-tune-v1 to start chatting
Load model with FastModel
pip install unsloth from unsloth import FastModel model, tokenizer = FastModel.from_pretrained( model_name="aidando73/llama-3.3-70b-instruct-code-agent-fine-tune-v1", max_seq_length=2048, )
- handler.py +30 -0
- test-handler.py +12 -0
handler.py
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from typing import Dict, List, Any
|
| 2 |
+
from unsloth import FastLanguageModel
|
| 3 |
+
|
| 4 |
+
class EndpointHandler():
|
| 5 |
+
def __init__(self, path=""):
|
| 6 |
+
# Preload all the elements you are going to need at inference.
|
| 7 |
+
# pseudo:
|
| 8 |
+
# self.model= load_model(path)
|
| 9 |
+
model, tokenizer = FastLanguageModel.from_pretrained(
|
| 10 |
+
model_name = "aidando73/llama-3.3-70b-instruct-code-agent-fine-tune-v1",
|
| 11 |
+
max_seq_length = 2048,
|
| 12 |
+
dtype = "float16",
|
| 13 |
+
load_in_4bit = True,
|
| 14 |
+
)
|
| 15 |
+
FastLanguageModel.for_inference(model)
|
| 16 |
+
self.model = model
|
| 17 |
+
self.tokenizer = tokenizer
|
| 18 |
+
|
| 19 |
+
def __call__(self, data: Dict[str, Any]) -> List[Dict[str, Any]]:
|
| 20 |
+
"""
|
| 21 |
+
data args:
|
| 22 |
+
inputs (:obj: `str` | `PIL.Image` | `np.array`)
|
| 23 |
+
kwargs
|
| 24 |
+
Return:
|
| 25 |
+
A :obj:`list` | `dict`: will be serialized and returned
|
| 26 |
+
"""
|
| 27 |
+
|
| 28 |
+
input_ids = self.tokenizer.encode(data["inputs"], return_tensors = "pt").to("cuda")
|
| 29 |
+
output = self.model.generate(input_ids, max_new_tokens = 128, pad_token_id = self.tokenizer.eos_token_id)
|
| 30 |
+
return [{"output": self.tokenizer.decode(output[0], skip_special_tokens = True)}]
|
test-handler.py
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from handler import EndpointHandler
|
| 2 |
+
|
| 3 |
+
# init handler
|
| 4 |
+
my_handler = EndpointHandler(path=".")
|
| 5 |
+
|
| 6 |
+
# prepare sample payload
|
| 7 |
+
input = {"inputs": "Hello World"}
|
| 8 |
+
|
| 9 |
+
# test the handler
|
| 10 |
+
output = my_handler(input)
|
| 11 |
+
|
| 12 |
+
print("output", output)
|