alexandrlukashov/text2json-dataset-12k
Viewer • Updated • 87.1k • 8 • 1
How to use boopathiraj/T5-Json-Parsing-Model with Transformers:
# Use a pipeline as a high-level helper
from transformers import pipeline
pipe = pipeline("text-generation", model="boopathiraj/T5-Json-Parsing-Model") # Load model directly
from transformers import AutoTokenizer, AutoModelForSeq2SeqLM
tokenizer = AutoTokenizer.from_pretrained("boopathiraj/T5-Json-Parsing-Model")
model = AutoModelForSeq2SeqLM.from_pretrained("boopathiraj/T5-Json-Parsing-Model")How to use boopathiraj/T5-Json-Parsing-Model with vLLM:
# Install vLLM from pip:
pip install vllm
# Start the vLLM server:
vllm serve "boopathiraj/T5-Json-Parsing-Model"
# Call the server using curl (OpenAI-compatible API):
curl -X POST "http://localhost:8000/v1/completions" \
-H "Content-Type: application/json" \
--data '{
"model": "boopathiraj/T5-Json-Parsing-Model",
"prompt": "Once upon a time,",
"max_tokens": 512,
"temperature": 0.5
}'docker model run hf.co/boopathiraj/T5-Json-Parsing-Model
How to use boopathiraj/T5-Json-Parsing-Model with SGLang:
# Install SGLang from pip:
pip install sglang
# Start the SGLang server:
python3 -m sglang.launch_server \
--model-path "boopathiraj/T5-Json-Parsing-Model" \
--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": "boopathiraj/T5-Json-Parsing-Model",
"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 "boopathiraj/T5-Json-Parsing-Model" \
--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": "boopathiraj/T5-Json-Parsing-Model",
"prompt": "Once upon a time,",
"max_tokens": 512,
"temperature": 0.5
}'How to use boopathiraj/T5-Json-Parsing-Model with Docker Model Runner:
docker model run hf.co/boopathiraj/T5-Json-Parsing-Model
Fine-tuned T5 model for structured JSON metadata extraction from unstructured text
T5-Json-Parsing-Model is a text-to-JSON generation model based on T5, specifically fine-tuned to:
Goal:
"extract metadata: ..."→{"type": "...", "name": "...", ...}
| Metric | Score | Interpretation |
|---|---|---|
| Exact-Match Accuracy | 4.33% | Very low — strict JSON format not followed |
| JSON Structural Accuracy | 1.33% | Almost no outputs are valid JSON |
| ROUGE-1 | 53.92 | Good unigram overlap |
| ROUGE-2 | 38.33 | Moderate bigram matching |
| ROUGE-L | 51.53 | Strong sequence preservation |
| BLEU Score | 27.69 | Decent n-gram precision |
Insight:
The model understands the content well (high ROUGE/BLEU), but fails to produce valid JSON syntax.
extract metadata: John Smith, born in 1980, lives in New York, works as a data scientist.
### Inference :
```python
input_text = "extract metadata: John Smith, born in 1980, lives in New York, works as a data scientist."
input_ids = tokenizer(input_text, return_tensors="pt", truncation=True, padding=True).input_ids
# Generate text using the model's generate method
generated_ids = model.generate(input_ids, max_new_tokens=50, num_beams=5, early_stopping=True)
# Decode the generated IDs to text
decoded_output = tokenizer.decode(generated_ids[0], skip_special_tokens=True)
print(json.loads("{" + decoded_output[1:-1] + "}"))
{'type': 'person', 'name': 'John Smith', 'yr_born': '1980', 'location': 'New York'}
Base model
google-t5/t5-small