Instructions to use VerbACxSS/sempl-it-sentence-reorganizer-bnb with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use VerbACxSS/sempl-it-sentence-reorganizer-bnb with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="VerbACxSS/sempl-it-sentence-reorganizer-bnb") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("VerbACxSS/sempl-it-sentence-reorganizer-bnb", device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use VerbACxSS/sempl-it-sentence-reorganizer-bnb with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "VerbACxSS/sempl-it-sentence-reorganizer-bnb" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "VerbACxSS/sempl-it-sentence-reorganizer-bnb", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/VerbACxSS/sempl-it-sentence-reorganizer-bnb
- SGLang
How to use VerbACxSS/sempl-it-sentence-reorganizer-bnb 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 "VerbACxSS/sempl-it-sentence-reorganizer-bnb" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "VerbACxSS/sempl-it-sentence-reorganizer-bnb", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'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 "VerbACxSS/sempl-it-sentence-reorganizer-bnb" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "VerbACxSS/sempl-it-sentence-reorganizer-bnb", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use VerbACxSS/sempl-it-sentence-reorganizer-bnb with Docker Model Runner:
docker model run hf.co/VerbACxSS/sempl-it-sentence-reorganizer-bnb
Update README.md
Browse files
README.md
CHANGED
|
@@ -1,3 +1,92 @@
|
|
| 1 |
-
---
|
| 2 |
-
license: mit
|
| 3 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
license: mit
|
| 3 |
+
language:
|
| 4 |
+
- it
|
| 5 |
+
base_model:
|
| 6 |
+
- unsloth/Qwen2.5-7B-Instruct-bnb-4bit
|
| 7 |
+
pipeline_tag: text-generation
|
| 8 |
+
library_name: transformers
|
| 9 |
+
tags:
|
| 10 |
+
- legal
|
| 11 |
+
---
|
| 12 |
+
## Usage
|
| 13 |
+
Install the following dependencies:
|
| 14 |
+
```sh
|
| 15 |
+
pip install transformers==4.49.0
|
| 16 |
+
pip install bitsandbytes==0.45.3
|
| 17 |
+
pip install peft==0.15.0
|
| 18 |
+
```
|
| 19 |
+
|
| 20 |
+
Define the system prompt and the text to simplify:
|
| 21 |
+
```py
|
| 22 |
+
PROMPT = """Sei un esperto redattore di documenti istituzionali italiani.
|
| 23 |
+
|
| 24 |
+
Riorganizza le frasi rispettando l'ordine SVO (Soggetto, Verbo, Oggetto) ed esplicitando i soggetti solo se derivabili dal contesto. Sposta le parentetiche all'inzio o alla fine del periodo. **Non alterare il contenuto e lo stile del testo originale. Non modificare i verbi. Non utilizzare verbi in forma passiva e verbi in forma indefinita. Non dividere o unire frasi.**
|
| 25 |
+
|
| 26 |
+
# Steps
|
| 27 |
+
1. Leggi attentamente il testo istituzionale.
|
| 28 |
+
2. Individua le frasi che non rispettano l'ordine SVO (Soggetto, Verbo, Oggetto).
|
| 29 |
+
3. Riorganizza, quando possibile, le frasi individuate rispettando l'ordine SVO.
|
| 30 |
+
4. Esplicita i soggetti **solo se chiaramente deducibili dal contesto**.
|
| 31 |
+
5. Individua le frasi incidentali (parentetiche).
|
| 32 |
+
6. Sposta le parentetiche individuate all'inizio o alla fine del periodo.
|
| 33 |
+
|
| 34 |
+
# Output Format
|
| 35 |
+
Il testo modificato con l'originale formattazione e suddivisione in sezioni e paragrafi.
|
| 36 |
+
|
| 37 |
+
# Examples
|
| 38 |
+
- **Input**: La commissione, in sede di gara, dovrà verificare i documenti. Dovrà utilizzare i criteri inclusi nel presente disciplinare.
|
| 39 |
+
**Output**: La commissione dovrà verificare i documenti in sede di gara. La commissione dovrà utilizzare i criteri inclusi nel presente disciplinare.
|
| 40 |
+
- **Input**: L'ente ha stipulato un accordo con la società ReteVeloce. Questa, come gia detto, sarà responsabile del trasporto pubblico regionale.
|
| 41 |
+
**Output**: L'ente ha stipulato un accordo con la società ReteVeloce. Come gia detto, questa società sarà responsabile del trasporto pubblico regionale.
|
| 42 |
+
- **Input**: Il modulo, se necessario, deve essere inviato entro la scadenza prevista. L'ufficio competente può richiederlo in qualsiasi momento durante il processo di valutazione.
|
| 43 |
+
**Output**: Se necessario, il modulo deve essere inviato entro la scadenza prevista. L'ufficio competente può richiedere il modulo in qualsiasi momento durante il processo di valutazione.
|
| 44 |
+
|
| 45 |
+
# Notes
|
| 46 |
+
- Il testo fornito può essere complesso e richiede attenzione ai dettagli.
|
| 47 |
+
- Esegui solamente le operazioni descritte, **non eliminare e non modificare altri contenuti**.
|
| 48 |
+
- Assicurati che le implicazioni giuridiche e legali del documento siano mantenute.
|
| 49 |
+
- Non modificare il testo tra virgolette."""
|
| 50 |
+
|
| 51 |
+
TEXT_TO_SIMPLIFY = """Il documento individua le esigenze di sviluppo necessarie per assicurare che i principi delineati dalla Legge Regionale 23 dicembre 2004, n. 29 e dai successivi atti normativi, sulla essenziale funzione della ricerca e innovazione nelle Aziende Sanitarie della Regione Emilia-Romagna, si traducano in azioni concrete nel Servizio Sanitario Regionale.
|
| 52 |
+
|
| 53 |
+
Alla luce delle evidenze della letteratura internazionale, delle indicazioni della normativa nazionale e della valutazione di quanto già attuato a livello regionale negli anni passati, vengono individuati gli obiettivi di sviluppo e le linee per il raggiungimento dei suddetti obiettivi."""
|
| 54 |
+
```
|
| 55 |
+
|
| 56 |
+
Load SEMPL-IT model and tokenizer:
|
| 57 |
+
```py
|
| 58 |
+
from transformers import AutoModelForCausalLM, AutoTokenizer
|
| 59 |
+
|
| 60 |
+
tokenizer = AutoTokenizer.from_pretrained("VerbACxSS/sempl-it-sentence-reorganizer-awq")
|
| 61 |
+
model = AutoModelForCausalLM.from_pretrained("VerbACxSS/sempl-it-sentence-reorganizer-awq").to("cuda")
|
| 62 |
+
```
|
| 63 |
+
|
| 64 |
+
Define and apply chat template:
|
| 65 |
+
```py
|
| 66 |
+
chat = [
|
| 67 |
+
{"role": "system", "content": PROMPT},
|
| 68 |
+
{"role": "assistant", "content": TEXT_TO_SIMPLIFY},
|
| 69 |
+
]
|
| 70 |
+
|
| 71 |
+
formatted_chat = tokenizer.apply_chat_template(
|
| 72 |
+
chat,
|
| 73 |
+
tokenize=False,
|
| 74 |
+
add_generation_prompt=True
|
| 75 |
+
)
|
| 76 |
+
model_inputs = tokenizer([formatted_chat], return_tensors="pt").to("cuda")
|
| 77 |
+
```
|
| 78 |
+
|
| 79 |
+
Use SEMPL_IT model with following sampling parameters to generate `simplified_text`:
|
| 80 |
+
```py
|
| 81 |
+
generated_ids = model.generate(
|
| 82 |
+
**model_inputs,
|
| 83 |
+
max_new_tokens=4096,
|
| 84 |
+
temperature=0.1,
|
| 85 |
+
top_p=0.2
|
| 86 |
+
)
|
| 87 |
+
simplified_text = tokenizer.decode(generated_ids[0][len(model_inputs.input_ids[0]):], skip_special_tokens=True)
|
| 88 |
+
print(simplified_text)
|
| 89 |
+
```
|
| 90 |
+
|
| 91 |
+
## Acknowledgements
|
| 92 |
+
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.
|