Instructions to use myatticus/Contracts with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use myatticus/Contracts with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="myatticus/Contracts")# pip install -U transformers accelerate # Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("myatticus/Contracts") model = AutoModelForCausalLM.from_pretrained("myatticus/Contracts", device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use myatticus/Contracts with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "myatticus/Contracts" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "myatticus/Contracts", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/myatticus/Contracts
- SGLang
How to use myatticus/Contracts with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "myatticus/Contracts" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "myatticus/Contracts", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "myatticus/Contracts" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "myatticus/Contracts", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use myatticus/Contracts with Docker Model Runner:
docker model run hf.co/myatticus/Contracts
Download handler.py from myatticus/Contracts: direct link, hf CLI and curl.
- Browser
- Download file 1.03 kB
-
https://huggingface.co/myatticus/Contracts/resolve/refs%2Fpr%2F1/handler.py
- Command line
-
hf download hf://myatticus/Contracts@refs/pr/1/handler.py
-
curl -L -o handler.py https://huggingface.co/myatticus/Contracts/resolve/refs%2Fpr%2F1/handler.py
1.03 kB
| from typing import Any, Dict | |
| import torch | |
| import transformers | |
| from transformers import AutoModelForCausalLM, AutoTokenizer | |
| from langchain.llms import HuggingFacePipeline | |
| dtype = torch.bfloat16 if torch.cuda.get_device_capability()[0] == 8 else torch.float16 | |
| class EndpointHandler: | |
| def __init__(self, path=""): | |
| tokenizer = AutoTokenizer.from_pretrained(path, trust_remote_code=True) | |
| model = AutoModelForCausalLM.from_pretrained( | |
| path, | |
| return_dict=True, | |
| device_map="auto", | |
| # load_in_8bit=True, | |
| torch_dtype=dtype, | |
| trust_remote_code=True | |
| ) | |
| self.pipeline = transformers.pipeline( | |
| "text-generation", model=model, tokenizer=tokenizer, repetition_penalty=1.4, temperature=0.2, max_new_tokens = 512 | |
| ) | |
| def __call__(self, data: Dict[str, Any]) -> Dict[str, Any]: | |
| prompt = data.pop("inputs", data) | |
| llm = HuggingFacePipeline(pipeline=self.pipeline) | |
| return llm(prompt) |