Model Card for Model ID
Model Details
Model Description
This is the model card of a ๐ค transformers model that has been pushed on the Hub. This model card has been automatically generated.
- Developed by: [More Information Needed]
- Funded by [optional]: [More Information Needed]
- Shared by [optional]: [More Information Needed]
- Model type: [More Information Needed]
- Language(s) (NLP): [More Information Needed]
- License: [More Information Needed]
- Finetuned from model [optional]: [More Information Needed]
Model Sources [optional]
- Repository: [More Information Needed]
- Paper [optional]: [More Information Needed]
- Demo [optional]: [More Information Needed]
Uses
Direct Use
[More Information Needed]
Downstream Use [optional]
[More Information Needed]
Out-of-Scope Use
[More Information Needed]
Bias, Risks, and Limitations
[More Information Needed]
Recommendations
Users (both direct and downstream) should be made aware of the risks, biases and limitations of the model. More information needed for further recommendations.
How to Get Started with the Model
Use the code below to get started with the model.
[More Information Needed]
Training Details
Training Data
[More Information Needed]
Training Procedure
Preprocessing [optional]
[More Information Needed]
Training Hyperparameters
- Training regime: [More Information Needed]
Speeds, Sizes, Times [optional]
[More Information Needed]
Evaluation
Testing Data, Factors & Metrics
Testing Data
[More Information Needed]
Factors
[More Information Needed]
Metrics
[More Information Needed]
Results
[More Information Needed]
Summary
Model Examination [optional]
[More Information Needed]
Environmental Impact
Carbon emissions can be estimated using the Machine Learning Impact calculator presented in Lacoste et al. (2019).
- Hardware Type: [More Information Needed]
- Hours used: [More Information Needed]
- Cloud Provider: [More Information Needed]
- Compute Region: [More Information Needed]
- Carbon Emitted: [More Information Needed]
Technical Specifications [optional]
Model Architecture and Objective
[More Information Needed]
Compute Infrastructure
[More Information Needed]
Hardware
[More Information Needed]
Software
[More Information Needed]
Citation [optional]
BibTeX:
[More Information Needed]
APA:
[More Information Needed]
Glossary [optional]
[More Information Needed]
More Information [optional]
[More Information Needed]
Model Card Authors [optional]
[More Information Needed]
Model Card Contact
[More Information Needed]
Inference (pseudo-code)
from transformers import AutoModelForCausalLM, AutoTokenizer
import torch, json
model_id = "mohdusman001/pi2-table-llama3-8b-sft_final"
tokenizer = AutoTokenizer.from_pretrained(model_id, use_fast=True)
tokenizer.padding_side = "left"
if tokenizer.pad_token is None:
tokenizer.pad_token = tokenizer.eos_token
model = AutoModelForCausalLM.from_pretrained(
model_id,
torch_dtype=torch.bfloat16,
device_map="auto",
attn_implementation="flash_attention_2",
)
# Example input (text + schema)
text = "amanda renae carraway-marsh -lrb- born january 25 , 1978 -rrb- is a beauty queen and model from manhattan , kansas who was crowned miss kansas usa 1999 . she competed in the miss usa 1999 pageant but was unplaced . she was also miss kansas teen usa 1996 ."
schema = {
"table_id": "t0_kv",
"columns": [
{
"name": "field",
"path": [
"field"
]
},
{
"name": "value",
"path": [
"value"
]
}
],
"n_cols": 2
}
user_prompt = (
"[SCHEMA]\n"
+ json.dumps(schema, ensure_ascii=False)
+ "\n<|document|>\n"
+ text
)
messages = [{"role": "user", "content": user_prompt}]
chat = tokenizer.apply_chat_template(
messages,
tokenize=False,
add_generation_prompt=True,
)
inputs = tokenizer(chat, return_tensors="pt").to(model.device)
with torch.no_grad():
out = model.generate(
**inputs,
max_new_tokens=512,
do_sample=True,
temperature=0.2,
top_p=0.95,
eos_token_id=tokenizer.eos_token_id,
pad_token_id=tokenizer.pad_token_id,
)
input_len = inputs["input_ids"].shape[1]
gen_ids = out[0, input_len:]
table_text = tokenizer.decode(gen_ids, skip_special_tokens=True)
# Parse JSONL table
rows = [json.loads(ln) for ln in table_text.splitlines() if ln.strip()]
print(rows)
The script infer_and_upload_pi2.py (not part of this repo by default) demonstrates
how to run batched inference on a shuffled subset of a JSONL test file, and uploads
a rich JSONL of results to the repo.
The file pi2_table_inference_1000_samples.jsonl contains 4 important fields for each sample:
input_text: the original text passage.input_schema: the JSON schema used to define the table columns.model_output: raw text that the model generated (JSONL lines).output_table: parsed JSON objects (one per row).
Example sample (truncated)
Input text (truncated):
amanda renae carraway-marsh -lrb- born january 25 , 1978 -rrb- is a beauty queen and model from manhattan , kansas who was crowned miss kansas usa 1999 . she competed in the miss usa 1999 pageant but was unplaced . she was also miss kansas teen usa 1996 .
Input schema:
{
"table_id": "t0_kv",
"columns": [
{
"name": "field",
"path": [
"field"
]
},
{
"name": "value",
"path": [
"value"
]
}
],
"n_cols": 2
}
Predicted table (first few rows):
[
"field",
"value"
]
```\n\n---\n\n## Inference (pseudo-code)
```python
from transformers import AutoModelForCausalLM, AutoTokenizer
import torch, json
model_id = "mohdusman001/pi2-table-llama3-8b-sft_final"
tokenizer = AutoTokenizer.from_pretrained(model_id, use_fast=True)
tokenizer.padding_side = "left"
if tokenizer.pad_token is None:
tokenizer.pad_token = tokenizer.eos_token
model = AutoModelForCausalLM.from_pretrained(
model_id,
torch_dtype=torch.bfloat16,
device_map="auto",
attn_implementation="flash_attention_2",
)
# Example input (text + schema)
text = "amanda renae carraway-marsh -lrb- born january 25 , 1978 -rrb- is a beauty queen and model from manhattan , kansas who was crowned miss kansas usa 1999 . she competed in the miss usa 1999 pageant but was unplaced . she was also miss kansas teen usa 1996 ."
schema = {
"table_id": "t0_kv",
"columns": [
{
"name": "field",
"path": [
"field"
]
},
{
"name": "value",
"path": [
"value"
]
}
],
"n_cols": 2
}
user_instruction = (
"You are a table extraction model. Given a JSON schema and a document, "
"you must extract rows that match the schema.\n"
"Return the table as JSON Lines (JSONL): one valid JSON object per line, "
"with keys exactly equal to the column names in the schema.\n"
"Do NOT output any explanations, natural language, markdown, or code โ "
"only the JSONL table rows.\n\n"
)
user_prompt = (
user_instruction
+ "[SCHEMA]\n"
+ json.dumps(schema, ensure_ascii=False)
+ "\n<|document|>\n"
+ text
)
messages = [{"role": "user", "content": user_prompt}]
chat = tokenizer.apply_chat_template(
messages,
tokenize=False,
add_generation_prompt=True,
)
inputs = tokenizer(chat, return_tensors="pt").to(model.device)
with torch.no_grad():
out = model.generate(
**inputs,
max_new_tokens=512,
do_sample=False,
eos_token_id=tokenizer.eos_token_id,
pad_token_id=tokenizer.pad_token_id,
)
input_len = inputs["input_ids"].shape[1]
gen_ids = out[0, input_len:]
table_text = tokenizer.decode(gen_ids, skip_special_tokens=True)
# Parse JSONL table
rows = [json.loads(ln) for ln in table_text.splitlines() if ln.strip()]
print(rows)
The script infer_and_upload_pi2.py demonstrates how to run batched inference on a
shuffled subset of a JSONL test file, and uploads a rich JSONL of results to the repo.
The file pi2_table_inference_1000_samples.jsonl contains, for each sample:
text: the original text passage.schema: the JSON schema used to define the table columns.model_output: raw text that the model generated (JSONL lines).rows: parsed JSON objects (one per row).table: a structured table withtable_id,columns, anddatamatrix.
Example sample (truncated)
Input text (truncated):
amanda renae carraway-marsh -lrb- born january 25 , 1978 -rrb- is a beauty queen and model from manhattan , kansas who was crowned miss kansas usa 1999 . she competed in the miss usa 1999 pageant but was unplaced . she was also miss kansas teen usa 1996 .
Input schema:
{
"table_id": "t0_kv",
"columns": [
{
"name": "field",
"path": [
"field"
]
},
{
"name": "value",
"path": [
"value"
]
}
],
"n_cols": 2
}
Predicted table (first few rows):
{
"table_id": "t0_kv",
"columns": [
{
"name": "field",
"path": [
"field"
]
},
{
"name": "value",
"path": [
"value"
]
}
],
"data": [
[
"amanda renae carraway-marsh",
"born january 25, 1978 -rrb- is a beauty queen and model from manhattan, kansas who was crowned miss kansas usa 1999. she competed in the miss usa 1999 pageant but was unplaced. she was also miss kansas teen usa 1996."
]
]
}
```\n
---
## Inference (pseudo-code)
```python
from transformers import AutoModelForCausalLM, AutoTokenizer
import torch, json
model_id = "mohdusman001/pi2-table-llama3-8b-sft_final"
tokenizer = AutoTokenizer.from_pretrained(model_id, use_fast=True)
tokenizer.padding_side = "left"
if tokenizer.pad_token is None:
tokenizer.pad_token = tokenizer.eos_token
model = AutoModelForCausalLM.from_pretrained(
model_id,
torch_dtype=torch.bfloat16,
device_map="auto",
attn_implementation="flash_attention_2",
)
# Example input (text + schema)
text = "amanda renae carraway-marsh -lrb- born january 25 , 1978 -rrb- is a beauty queen and model from manhattan , kansas who was crowned miss kansas usa 1999 . she competed in the miss usa 1999 pageant but was unplaced . she was also miss kansas teen usa 1996 ."
schema = {
"table_id": "t0_kv",
"columns": [
{
"name": "field",
"path": [
"field"
]
},
{
"name": "value",
"path": [
"value"
]
}
],
"n_cols": 2
}
user_instruction = (
"You are a table extraction model. Given a JSON schema and a document, "
"you must extract rows that match the schema.
"
"Return the table as JSON Lines (JSONL): one valid JSON object per line, "
"with keys exactly equal to the column names in the schema.
"
"For key-value schemas (e.g. columns ['slot', 'value'] or ['field', 'value']), "
"you must output one row per attribute (e.g. name, eatType, area, etc.).
"
"Do NOT output any explanations, natural language, markdown, or code โ "
"only the JSONL table rows.
"
)
user_prompt = (
user_instruction
+ "[SCHEMA]
"
+ json.dumps(schema, ensure_ascii=False)
+ "
<|document|>
"
+ text
)
messages = [{"role": "user", "content": user_prompt}]
chat = tokenizer.apply_chat_template(
messages,
tokenize=False,
add_generation_prompt=True,
)
inputs = tokenizer(chat, return_tensors="pt").to(model.device)
with torch.no_grad():
out = model.generate(
**inputs,
max_new_tokens=512,
do_sample=False,
eos_token_id=tokenizer.eos_token_id,
pad_token_id=tokenizer.pad_token_id,
)
input_len = inputs["input_ids"].shape[1]
gen_ids = out[0, input_len:]
table_text = tokenizer.decode(gen_ids, skip_special_tokens=True)
# Parse JSONL table
rows = [json.loads(ln) for ln in table_text.splitlines() if ln.strip()]
print(rows)
The script infer_and_upload_pi2.py demonstrates how to run batched inference on a
shuffled subset of a JSONL test file, and uploads a rich JSONL of results to the repo.
The file pi2_table_inference_1000_samples.jsonl contains, for each sample:
text: the original text passage.schema: the JSON schema used to define the table columns.model_output: raw text that the model generated (JSONL lines).rows: parsed JSON objects (one per row).table: a structured table withtable_id,columns, anddatamatrix.
Example sample (truncated)
Input text (truncated):
amanda renae carraway-marsh -lrb- born january 25 , 1978 -rrb- is a beauty queen and model from manhattan , kansas who was crowned miss kansas usa 1999 . she competed in the miss usa 1999 pageant but was unplaced . she was also miss kansas teen usa 1996 .
Input schema:
{
"table_id": "t0_kv",
"columns": [
{
"name": "field",
"path": [
"field"
]
},
{
"name": "value",
"path": [
"value"
]
}
],
"n_cols": 2
}
Predicted table (first few rows):
{
"table_id": "t0_kv",
"columns": [
{
"name": "field",
"path": [
"field"
]
},
{
"name": "value",
"path": [
"value"
]
}
],
"data": [
[
"amanda renae carraway-marsh",
"born"
],
[
"january 25, 1978",
"born"
],
[
"amanda renae carraway-marsh",
"beauty queen and model"
]
]
}
- Downloads last month
- 39