Skip to content

Commit

Permalink
Add simple document question answering unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
xenova committed Sep 25, 2023
1 parent dc6fc56 commit 5f2ab62
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions tests/pipelines.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -1325,4 +1325,29 @@ describe('Pipelines', () => {
await detector.dispose();
}, MAX_TEST_EXECUTION_TIME);
});

describe('Document question answering', () => {

// List all models which will be tested
const models = [
'naver-clova-ix/donut-base-finetuned-docvqa',
];
const image = 'https://huggingface.co/datasets/Xenova/transformers.js-docs/resolve/main/invoice.png';
const question = 'What is the invoice number?';

it(models[0], async () => {
let qa_pipeline = await pipeline('document-question-answering', m(models[0]));

// basic
{
let output = await qa_pipeline(image, question);
let expected = [{ answer: 'us-001' }];
compare(output, expected);
}

await qa_pipeline.dispose();

}, MAX_TEST_EXECUTION_TIME);
});

});

0 comments on commit 5f2ab62

Please sign in to comment.