Run this model with HF Jobs
Run am5uc/ServiceNow_Table_Question_Answering on Hugging Face's managed compute, monitor its progress, and retrieve the results when it's done.
Paste one of these prompts into your coding agent:
Fine-tune on my dataset
Use HF Jobs to fine-tune https://huggingface.co/am5uc/ServiceNow_Table_Question_Answering. Ask me which dataset to train on, then push the fine-tuned model to a new model repo. Run `hf jobs --help` first to learn the CLI.
Run batch inference
Use HF Jobs to run batch inference with https://huggingface.co/am5uc/ServiceNow_Table_Question_Answering on the inputs in a mounted HF Bucket. Ask me which Bucket to use, then write the outputs back to it and keep each input ID. Run `hf jobs --help` first to learn the CLI.
Instructions to use am5uc/ServiceNow_Table_Question_Answering with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use am5uc/ServiceNow_Table_Question_Answering with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("table-question-answering", model="am5uc/ServiceNow_Table_Question_Answering")# pip install -U transformers accelerate # Load model directly from transformers import AutoTokenizer, AutoModelForTableQuestionAnswering tokenizer = AutoTokenizer.from_pretrained("am5uc/ServiceNow_Table_Question_Answering") model = AutoModelForTableQuestionAnswering.from_pretrained("am5uc/ServiceNow_Table_Question_Answering", device_map="auto") - Notebooks
- Google Colab
- Kaggle
Update README.md
Browse files49 unmodified lines5051525354555657585927 unmodified lines8788899091929394959697989910010110210310410534 unmodified lines14014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834949 unmodified lines| mistralai/Mistral-7B-Instruct-v0.3 | 0 | Exact Match: 0.0346 Fuzzy Match: 0.4744 | | | | || meta-llama/Llama-3.2-1B | 0.0133 | | | | | |## UsageThe prompt for the TAPAS model should be a natural language question paired with a structured table that can be passed in in dataframe format. The prompt should look like this:```pythonquestion = "How many Hardware Upgrade changes are still pending?"table_df = pd.DataFrame({"change_id": [27 unmodified lines"2023-05-30"]})```Or you could define table in json format and then have table = pd.DataFrame(table) in your tokenizer.## Expected Output FormatYou tokenize the inputs and then perform a specific function to get outputs, which are the aggregation operation, answer, and predicted_cells. You can just grab the middle value which is the predicted answer.```python# Tokenize both Question and Table togetherinputs = tokenizer(table=table_df, queries=[question], padding='max_length', return_tensors='pt')# Model prediction##--- Helper function ---def get_final_answer(model, tokenizer, inputs, table_df):outputs = model(**inputs)34 unmodified linesreturn agg_op, answer, predicted_cells_, answer, _ = get_final_answer(model, tokenizer, inputs, table_df)print(answer)```If the question is asking for a count, like how many changes have been completed, the answer would just be one number.If it is asking a question about the most common incident status or root cause, the answer would be the root cause or status the modelpredicts.## LimitationsThe model does still not come close to a 100% accuracy. Possiblly using a larger model could help. It does seem to only be able to take in a limited size for tables, larger than a whole system. Once again, possibly a larger model could help. Also this needs to take in a question and table in dataframe format, so more preocessing is necessary than just a regular prompt.## Prompt Format## Model Details### Model Description<!-- Provide a longer summary of what this model is. -->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]<!-- Provide the basic links for the model. -->- **Repository:** [More Information Needed]- **Paper [optional]:** [More Information Needed]- **Demo [optional]:** [More Information Needed]## Uses<!-- Address questions around how the model is intended to be used, including the foreseeable users of the model and those affected by the model. -->### Direct Use<!-- This section is for the model use without fine-tuning or plugging into a larger ecosystem/app. -->[More Information Needed]### Downstream Use [optional]<!-- This section is for the model use when fine-tuned for a task, or when plugged into a larger ecosystem/app -->[More Information Needed]### Out-of-Scope Use<!-- This section addresses misuse, malicious use, and uses that the model will not work well for. -->[More Information Needed]## Bias, Risks, and Limitations<!-- This section is meant to convey both technical and sociotechnical limitations. -->[More Information Needed]### Recommendations<!-- This section is meant to convey recommendations with respect to the bias, risk, and technical limitations. -->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 ModelUse the code below to get started with the model.[More Information Needed]## Training Details### Training Data<!-- This should link to a Dataset Card, perhaps with a short stub of information on what the training data is all about as well as documentation related to data pre-processing or additional filtering. -->[More Information Needed]### Training Procedure<!-- This relates heavily to the Technical Specifications. Content here should link to that section when it is relevant to the training procedure. -->#### Preprocessing [optional][More Information Needed]#### Training Hyperparameters- **Training regime:** [More Information Needed] <!--fp32, fp16 mixed precision, bf16 mixed precision, bf16 non-mixed precision, fp16 non-mixed precision, fp8 mixed precision -->#### Speeds, Sizes, Times [optional]<!-- This section provides information about throughput, start/end time, checkpoint size if relevant, etc. -->[More Information Needed]## Evaluation<!-- This section describes the evaluation protocols and provides the results. -->### Testing Data, Factors & Metrics#### Testing Data<!-- This should link to a Dataset Card if possible. -->[More Information Needed]#### Factors<!-- These are the things the evaluation is disaggregating by, e.g., subpopulations or domains. -->[More Information Needed]#### Metrics<!-- These are the evaluation metrics being used, ideally with a description of why. -->[More Information Needed]### Results[More Information Needed]#### Summary## Model Examination [optional]<!-- Relevant interpretability work for the model goes here -->[More Information Needed]## Environmental Impact<!-- Total emissions (in grams of CO2eq) and additional considerations, such as electricity usage, go here. Edit the suggested text below accordingly -->Carbon emissions can be estimated using the [Machine Learning Impact calculator](https://mlco2.github.io/impact#compute) presented in [Lacoste et al. (2019)](https://arxiv.org/abs/1910.09700).- **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]<!-- If there is a paper or blog post introducing the model, the APA and Bibtex information for that should go in this section. -->**BibTeX:**[More Information Needed]**APA:**[More Information Needed]## Glossary [optional]<!-- If relevant, include terms and calculations in this section that can help readers understand the model or model card. -->[More Information Needed]## More Information [optional][More Information Needed]## Model Card Authors [optional][More Information Needed]## Model Card Contact[More Information Needed]49 unmodified lines5051525354555657585960616263646527 unmodified lines9394959697989910010110210310434 unmodified lines13914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625749 unmodified lines| mistralai/Mistral-7B-Instruct-v0.3 | 0 | Exact Match: 0.0346 Fuzzy Match: 0.4744 | | | | || meta-llama/Llama-3.2-1B | 0.0133 | | | | | |## Usage and Intended UsesThis model is designed for question answering over tabular data. It is mostly directed for querying ITSM tables (change, problem, and incident). It is used to answer questions, such as most common issues andnumber of records in varying categories.```pythonsaved_path = "/scratch/am5uc/models/cache/tapas_finetuned_base_model"tokenizer = TapasTokenizer.from_pretrained(saved_path)model = TapasForQuestionAnswering.from_pretrained(saved_path)question = "How many Hardware Upgrade changes are still pending?"table_df = pd.DataFrame({"change_id": [27 unmodified lines"2023-05-30"]})# Tokenize both Question and Table togetherinputs = tokenizer(table=table_df, queries=[question], padding='max_length', return_tensors='pt')# Model prediction# --- Helper function ---def get_final_answer(model, tokenizer, inputs, table_df):outputs = model(**inputs)34 unmodified linesreturn agg_op, answer, predicted_cells_, answer, _ = get_final_answer(model, tokenizer, inputs, table_df)print(answer)```## Prompt FormatThe prompt for the TAPAS model should be a natural language question paired with a structured table that can be passed in in dataframe format. TAPAS does not work withjust one prompt and generally reqires a question and a table dataframe to work.```pythonquestion = "How many Hardware Upgrade changes are still pending?"table_df = pd.DataFrame({"change_id": ["CHG3000","CHG3001","CHG3002","CHG3003"],"category": ["Security Patch","Software Update","Hardware Upgrade","Software Update"],"status": ["Rejected","In Progress","In Progress","Completed"],"approved_by": ["","Manager2","","Admin1"],"implementation_date": ["","","","2023-05-30"]})inputs = tokenizer(table=table_df, queries=[question], padding='max_length', return_tensors='pt')```Or you could define table in json format and then have table = pd.DataFrame(table) in your tokenizer.## Expected Output FormatYou tokenize the inputs and then perform a specific function to get outputs, which are the aggregation operation, answer, and predicted_cells. You can just grab the middle value which is the predicted answer.```python# Tokenize both Question and Table togetherinputs = tokenizer(table=table_df, queries=[question], padding='max_length', return_tensors='pt')# Model prediction##--- Helper function ---def get_final_answer(model, tokenizer, inputs, table_df):outputs = model(**inputs)logits = outputs.logitslogits_agg = outputs.logits_aggregationpredicted_answer_coordinates, predicted_aggregation_indices = tokenizer.convert_logits_to_predictions(inputs,logits.detach(),logits_agg=logits_agg.detach())aggregation_operators = ["NONE", "SUM", "AVERAGE", "COUNT"]agg_op_idx = predicted_aggregation_indices[0] if predicted_aggregation_indices else 0agg_op = aggregation_operators[agg_op_idx]predicted_cells = []for coord in predicted_answer_coordinates[0]:cell_value = table_df.iat[coord[0], coord[1]]predicted_cells.append(cell_value)if agg_op == "COUNT":answer = len(predicted_cells)elif agg_op == "SUM":try:answer = sum(float(cell) for cell in predicted_cells)except ValueError:answer = "Could not SUM non-numeric cells"elif agg_op == "AVERAGE":try:answer = sum(float(cell) for cell in predicted_cells) / len(predicted_cells)except ValueError:answer = "Could not AVERAGE non-numeric cells"else: # NONEanswer = predicted_cellsreturn agg_op, answer, predicted_cells_, answer, _ = get_final_answer(model, tokenizer, inputs, table_df)print(answer)```If the question is asking for a count, like how many changes have been completed, the answer would just be one number.If it is asking a question about the most common incident status or root cause, the answer would be the root cause or status the modelpredicts.## LimitationsThe model does still not come close to a 100% accuracy. Possiblly using a larger model could help. It does seem to only be able to take in a limited size for tables, larger than a whole system. Once again, possibly a larger model could help. Also this needs to take in a question and table in dataframe format, so more preocessing is necessary than just a regular prompt.## Model Card Authors [optional]Abhinandan Mekap
README.md+99-191