Instructions to use turnipseason/latext5 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use turnipseason/latext5 with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="turnipseason/latext5")# Load model directly from transformers import AutoTokenizer, AutoModelForSeq2SeqLM tokenizer = AutoTokenizer.from_pretrained("turnipseason/latext5") model = AutoModelForSeq2SeqLM.from_pretrained("turnipseason/latext5", device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use turnipseason/latext5 with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "turnipseason/latext5" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "turnipseason/latext5", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/turnipseason/latext5
- SGLang
How to use turnipseason/latext5 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 "turnipseason/latext5" \ --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": "turnipseason/latext5", "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 "turnipseason/latext5" \ --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": "turnipseason/latext5", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use turnipseason/latext5 with Docker Model Runner:
docker model run hf.co/turnipseason/latext5
Updated usage example
Browse files
README.md
CHANGED
|
@@ -23,6 +23,7 @@ Usage example:
|
|
| 23 |
---
|
| 24 |
|
| 25 |
``` python
|
|
|
|
| 26 |
from transformers import AutoTokenizer, AutoModelForSeq2SeqLM
|
| 27 |
from IPython.display import display, Math, Latex
|
| 28 |
|
|
@@ -36,16 +37,16 @@ model.to(device)
|
|
| 36 |
def get_latex(text):
|
| 37 |
inputs = tokenizer(text, return_tensors='pt').to(device)
|
| 38 |
with torch.no_grad():
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
|
| 47 |
for h in hypotheses:
|
| 48 |
-
|
| 49 |
|
| 50 |
text = '''лямбда прописная квадрат минус три равно десять игрек куб
|
| 51 |
При этом шинус икс равен интеграл от экспоненты до трёх игрек штрих'''
|
|
|
|
| 23 |
---
|
| 24 |
|
| 25 |
``` python
|
| 26 |
+
import torch
|
| 27 |
from transformers import AutoTokenizer, AutoModelForSeq2SeqLM
|
| 28 |
from IPython.display import display, Math, Latex
|
| 29 |
|
|
|
|
| 37 |
def get_latex(text):
|
| 38 |
inputs = tokenizer(text, return_tensors='pt').to(device)
|
| 39 |
with torch.no_grad():
|
| 40 |
+
hypotheses = model.generate(
|
| 41 |
+
**inputs,
|
| 42 |
+
do_sample=True, num_return_sequences=1,
|
| 43 |
+
repetition_penalty=1.2,
|
| 44 |
+
max_length=len(text),
|
| 45 |
+
num_beams=10,
|
| 46 |
+
early_stopping=True
|
| 47 |
+
)
|
| 48 |
for h in hypotheses:
|
| 49 |
+
display(Latex(tokenizer.decode(h, skip_special_tokens=True)))
|
| 50 |
|
| 51 |
text = '''лямбда прописная квадрат минус три равно десять игрек куб
|
| 52 |
При этом шинус икс равен интеграл от экспоненты до трёх игрек штрих'''
|