sempl-it-v1
Collection
3 items • Updated
How to use VerbACxSS/sempl-it-gpt2-small-italian with Transformers:
# Use a pipeline as a high-level helper
from transformers import pipeline
pipe = pipeline("text-generation", model="VerbACxSS/sempl-it-gpt2-small-italian") # Load model directly
from transformers import AutoTokenizer, AutoModelForCausalLM
tokenizer = AutoTokenizer.from_pretrained("VerbACxSS/sempl-it-gpt2-small-italian")
model = AutoModelForCausalLM.from_pretrained("VerbACxSS/sempl-it-gpt2-small-italian", device_map="auto")How to use VerbACxSS/sempl-it-gpt2-small-italian with vLLM:
# Install vLLM from pip:
pip install vllm
# Start the vLLM server:
vllm serve "VerbACxSS/sempl-it-gpt2-small-italian"
# Call the server using curl (OpenAI-compatible API):
curl -X POST "http://localhost:8000/v1/completions" \
-H "Content-Type: application/json" \
--data '{
"model": "VerbACxSS/sempl-it-gpt2-small-italian",
"prompt": "Once upon a time,",
"max_tokens": 512,
"temperature": 0.5
}'docker model run hf.co/VerbACxSS/sempl-it-gpt2-small-italian
How to use VerbACxSS/sempl-it-gpt2-small-italian with SGLang:
# Install SGLang from pip:
pip install sglang
# Start the SGLang server:
python3 -m sglang.launch_server \
--model-path "VerbACxSS/sempl-it-gpt2-small-italian" \
--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": "VerbACxSS/sempl-it-gpt2-small-italian",
"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 "VerbACxSS/sempl-it-gpt2-small-italian" \
--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": "VerbACxSS/sempl-it-gpt2-small-italian",
"prompt": "Once upon a time,",
"max_tokens": 512,
"temperature": 0.5
}'How to use VerbACxSS/sempl-it-gpt2-small-italian with Docker Model Runner:
docker model run hf.co/VerbACxSS/sempl-it-gpt2-small-italian
from transformers import AutoTokenizer, AutoModelForCausalLM
tokenizer = AutoTokenizer.from_pretrained("VerbACxSS/sempl-it-gpt2-small-italian", model_max_length=1024)
model = AutoModelForCausalLM.from_pretrained("VerbACxSS/sempl-it-gpt2-small-italian")
model.eval()
text_to_simplify = 'Nella fattispecie, questo documento è di natura prescrittiva'
prompt = f'### [Input]:\n{text_to_simplify}\n\n###[Output]:\n'
x = tokenizer(prompt, max_length=1024, truncation=True, padding=True, return_tensors='pt').input_ids
y = model.generate(x, max_length=1024)[0]
y_dec = tokenizer.decode(y, max_length=1024, truncation=True)
output = y_dec.split('###[Output]:\n')[1].split('<|endoftext|>')[0].strip()
print(output)
This contribution is a result of the research conducted within the framework of the PRIN 2020 (Progetti di Rilevante Interesse Nazionale) "VerbACxSS: on analytic verbs, complexity, synthetic verbs, and simplification. For accessibility" (Prot. 2020BJKB9M), funded by the Italian Ministero dell'Università e della Ricerca.
Base model
GroNLP/gpt2-small-italian