Instructions to use BinaryLight1011/Context with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use BinaryLight1011/Context with Transformers:
# Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("BinaryLight1011/Context", device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- Unsloth Studio
How to use BinaryLight1011/Context 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 BinaryLight1011/Context 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 BinaryLight1011/Context to start chatting
Using HuggingFace Spaces for Unsloth
# No setup required # Open https://huggingface.co/spaces/unsloth/studio in your browser # Search for BinaryLight1011/Context to start chatting
Load model with FastModel
pip install unsloth from unsloth import FastModel model, tokenizer = FastModel.from_pretrained( model_name="BinaryLight1011/Context", max_seq_length=2048, )
Jefferson de Azevedo commited on
Delete handler.py
Browse files- handler.py +0 -30
handler.py
DELETED
|
@@ -1,30 +0,0 @@
|
|
| 1 |
-
from unsloth import FastLanguageModel
|
| 2 |
-
import torch
|
| 3 |
-
|
| 4 |
-
class EndpointHandler:
|
| 5 |
-
def __init__(self, path=""):
|
| 6 |
-
self.model, self.tokenizer = FastLanguageModel.from_pretrained(
|
| 7 |
-
model_name=path,
|
| 8 |
-
max_seq_length=2048,
|
| 9 |
-
dtype=None,
|
| 10 |
-
load_in_4bit=True,
|
| 11 |
-
)
|
| 12 |
-
FastLanguageModel.for_inference(self.model)
|
| 13 |
-
|
| 14 |
-
def __call__(self, data: dict):
|
| 15 |
-
inputs_text = data.pop("inputs", "")
|
| 16 |
-
parameters = data.pop("parameters", {})
|
| 17 |
-
|
| 18 |
-
inputs = self.tokenizer(
|
| 19 |
-
inputs_text,
|
| 20 |
-
return_tensors="pt"
|
| 21 |
-
).to("cuda")
|
| 22 |
-
|
| 23 |
-
outputs = self.model.generate(
|
| 24 |
-
**inputs,
|
| 25 |
-
max_new_tokens=parameters.get("max_new_tokens", 256),
|
| 26 |
-
temperature=parameters.get("temperature", 0.7),
|
| 27 |
-
do_sample=True,
|
| 28 |
-
)
|
| 29 |
-
|
| 30 |
-
return self.tokenizer.decode(outputs[0], skip_special_tokens=True)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|