youngermax/text-tagging
Viewer • Updated • 11.5k • 17 • 2
How to use youngermax/text-tagger-v1 with Transformers:
# Use a pipeline as a high-level helper
from transformers import pipeline
pipe = pipeline("text-generation", model="youngermax/text-tagger-v1") # Load model directly
from transformers import AutoTokenizer, AutoModelForCausalLM
tokenizer = AutoTokenizer.from_pretrained("youngermax/text-tagger-v1")
model = AutoModelForCausalLM.from_pretrained("youngermax/text-tagger-v1")How to use youngermax/text-tagger-v1 with vLLM:
# Install vLLM from pip:
pip install vllm
# Start the vLLM server:
vllm serve "youngermax/text-tagger-v1"
# Call the server using curl (OpenAI-compatible API):
curl -X POST "http://localhost:8000/v1/completions" \
-H "Content-Type: application/json" \
--data '{
"model": "youngermax/text-tagger-v1",
"prompt": "Once upon a time,",
"max_tokens": 512,
"temperature": 0.5
}'docker model run hf.co/youngermax/text-tagger-v1
How to use youngermax/text-tagger-v1 with SGLang:
# Install SGLang from pip:
pip install sglang
# Start the SGLang server:
python3 -m sglang.launch_server \
--model-path "youngermax/text-tagger-v1" \
--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": "youngermax/text-tagger-v1",
"prompt": "Once upon a time,",
"max_tokens": 512,
"temperature": 0.5
}'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 "youngermax/text-tagger-v1" \
--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": "youngermax/text-tagger-v1",
"prompt": "Once upon a time,",
"max_tokens": 512,
"temperature": 0.5
}'How to use youngermax/text-tagger-v1 with Docker Model Runner:
docker model run hf.co/youngermax/text-tagger-v1
This model identifies multiple topics related to the text in natural language. It is finetuned on youngermax/text-tagging for 3.5 epoch over ~1.3 hours on a free Kaggle P100.
input_ids = tokenizer.encode(prompt + '<|topic|>', return_tensors='pt').to('cuda')
# Generate text
output = model.generate(
input_ids,
max_length=1024,
num_return_sequences=1,
eos_token_id=tokenizer.eos_token_id,
pad_token_id=tokenizer.eos_token_id,
top_k=100,
top_p=0.5,
temperature=1
)
# Decode the output
text = tokenizer.decode(output[0], skip_special_tokens=False, early_stopping=True)
text = text[len(prompt):text.find('<|endoftext|>')]
topics = list(set(list(map(lambda x: x.strip(), text.split('<|topic|>')))[1:]))