Nodes/ComfyUI-Transformers/Table Question Answering
ComfyUI Node

Table Question Answering

Ask your data a question in the middle of a diffusion workflow

By kadirnar·Created 3 years ago·Updated 7 months ago· 25
Table Question Answering
    • answer
    question
    table_json{"Name": ["Alice", "Bob"], "Age": ["25", "30"]}
    model_namegoogle/tapas-base-finetuned-wtq

    This is the strangest node in the pack, and it knows it. TableQuestionAnsweringPipeline takes a question plus a JSON-encoded table, runs a Transformer trained specifically on the question-over-spreadsheets task, and returns the answer as a string. In a typical ComfyUI workflow - where "data" usually means a latent tensor - a node that reads tabular data feels like it wandered in from a different product. And yet it clicks once you think of ComfyUI as a general graph runner, not just an image machine: any workflow that juggles structured config (batch settings, prompt lists, per-item parameters) can offload its "look this up for me" step to this node instead of hand-maintaining it.

    It's from kadirnar/ComfyUI-Transformers, the pack that wraps Hugging Face's transformers.pipeline() as one node per task. The default model is Google's TAPAS (google/tapas-base-finetuned-wtq), which is a BERT-sized model trained to answer questions over tables by selecting cells rather than generating free text - that's why answers come out as clean, short strings like "Alice" or "25" instead of rambling prose.

    How it works

    The node parses your table_json string with json.loads, then calls pipeline("table-question-answering", model=model_name) with your query. The pipeline hands back a dict, and the node returns result["answer"]. The table format matters and it's specific: the expected shape is a dict of column name → list of row values, like the default:

    {"Name": ["Alice", "Bob"], "Age": ["25", "30"]}
    

    That's a two-row table. Every column must have the same number of entries; the node does no validation, so a ragged table will just blow up when TAPAS chokes on it.

    Inputs and outputs

    • question - a single-line STRING ("Who is the oldest?").
    • table_json - multiline STRING, the JSON table. This is the fiddly input; get the shape wrong and it crashes.
    • model_name - default TAPAS-WTQ, swap for any table-QA model on the Hub.
    • Output: answer - a STRING.

    One thing to know about TAPAS-WTQ: it was trained on Wikipedia tables with the WTQ dataset, so it's happiest with simple, factual lookups - "What is Alice's age?" - and noticeably worse on aggregation questions like "how many people are over 26?" The base-finetuned-wtq variant also answers with cell text, which keeps things parseable but limits it to whatever is literally in the cells.

    Installing and running it

    Standard pack install: search "ComfyUI-Transformers" in ComfyUI Manager, or

    cd ComfyUI/custom_nodes
    git clone https://github.com/kadirnar/ComfyUI-Transformers
    cd ComfyUI-Transformers
    pip install -r requirements.txt
    

    then restart. The README's cd custom/nodes is a typo - ignore it. First run downloads TAPAS (~440 MB) to ~/.cache/huggingface, so expect a stall on the console while it fetches.

    Where people get burned

    • Invalid JSON in table_json is the #1 failure - one stray comma and json.loads throws, killing the run. Validate the JSON in an editor before you paste it in.
    • Asking questions the table can't answer. TAPAS answers from cell content; if the info isn't in a column, you'll get a confident wrong cell, not "I don't know."
    • Every execution reloads the model. Like the rest of this pack, there's a cached pipeline loader in the source that these nodes never actually call, so each run pays a load penalty.

    The realistic verdict: this is a curiosity for most image workflows, a genuinely handy lookup block for anyone using ComfyUI as a general automation graph. If your use case is really "query structured data," a JSON-path utility node is lighter weight; if you want natural-language access to tables without writing code, this is the pack's answer.

    CategoryTransformers/NLP/TableQuestionAnswering

    Inputs (3)

    NameTypeDefaultDescription
    questionSTRING
    table_jsonSTRING{"Name": ["Alice", "Bob"], "Age": ["25", "30"]}
    model_nameSTRINGgoogle/tapas-base-finetuned-wtq

    Outputs (1)

    NameTypeDescription
    answerSTRING