Live data from Hacker News

Extracting financial disclosure and police reports with OpenAI Structured Output

gist.github.com

61–70 of 93 posts

Re: Extracting financial disclosure and police reports with OpenAI Structured Output

#61
post #58

Earlier quoted context omitted.

How are you going to find (not even talking about correcting) hallucinated errors? If money is involved and the LLM produces hallucination errors, how do you handle monetary impacts of such errors? How does that approach scale financially?

We tried all models from openai and google to get data from images and all of them made "mistakes". The images are tables with 4 columns and 10 rows of numbers and metadata above that are in a couple of fields. We had thousands of images already loaded and when we tried to check those previously loaded images we found quite a few errors.

Curious, did that make you "fall back" to more conservative OCR?

Or what else did you do to correct them?

Re: Extracting financial disclosure and police reports with OpenAI Structured Output

#62
post #42

I’ve had pretty dismal results doing the same with spreadsheets—even with the data nicely tagged (and numbers directly adjacent to the labels) GPT-4o would completely make up figures to satisfy the JSON schema passed to it. YMMV.

On the flip side I have had a lot of success parsing spreadsheets and other tables into their markdown or similar representation and pulling data out of that quite accurately.

Re: Extracting financial disclosure and police reports with OpenAI Structured Output

#63

Data extraction is definitely one of the most useful functions of LLM, however, in my experience a large model is necessary for a reliable extraction - I tested smaller, open-weights models and the performance was not sufficient. I wonder, did anyone try to fine-tune a model specifically for general formatted data extraction? My naive thinking is that this should be pretty doable - after all, it's basically just rest…

Have you looked into structured generation with a library like outlines? https://github.com/dottxt-ai/outlines

Re: Extracting financial disclosure and police reports with OpenAI Structured Output

#64
post #60

Adding to the list of "now try it with".... The SEC's EDGAR database (which is for SEC filings) is another nightmare ready to end. Extracting individual sections from a filing is, afaik, impossible pragmatically. I tried making two parsers: https://github.com/MegaManSec/SEC-Feed-Parser and https://github.com/MegaManSec/SEC-sec-incident-notifier but they're just hacks. Then just link it up to your automated investment…

Would you not want to read the XBRL from the filing? I thought those are now mandatory.

This is one of those interesting areas where its hard to innovate because the data is already available from most/all data vendors and its cheap and accurate enough that nobody is going to reinvent those processes but also too expensive for an individual to purchase.

Re: Extracting financial disclosure and police reports with OpenAI Structured Output

#65
post #63

Data extraction is definitely one of the most useful functions of LLM, however, in my experience a large model is necessary for a reliable extraction - I tested smaller, open-weights models and the performance was not sufficient. I wonder, did anyone try to fine-tune a model specifically for general formatted data extraction? My naive thinking is that this should be pretty doable - after all, it's basically just rest…

Have you looked into structured generation with a library like outlines? https://github.com/dottxt-ai/outlines

Yes! This library is great and definitely helps, but I still had problems with performance. For example, smaller models would still hallucinate when extracting a JSON field when the given field wasn't present in the text (I'd expect null, but it provided either an incorrect value from the text, or a totally made up value).

Re: Extracting financial disclosure and police reports with OpenAI Structured Output

#66
post #58

Earlier quoted context omitted.

How are you going to find (not even talking about correcting) hallucinated errors? If money is involved and the LLM produces hallucination errors, how do you handle monetary impacts of such errors? How does that approach scale financially?

We tried all models from openai and google to get data from images and all of them made "mistakes". The images are tables with 4 columns and 10 rows of numbers and metadata above that are in a couple of fields. We had thousands of images already loaded and when we tried to check those previously loaded images we found quite a few errors.

Multimodal LLMs are not up for these tasks imo. It can describe an image but its not great on tables and numbers. Now on the other hand, using something like Textract to get the text representation of the table and then feeding that into a LLM was a massive success for us.

Re: Extracting financial disclosure and police reports with OpenAI Structured Output

#67
post #42

I’ve had pretty dismal results doing the same with spreadsheets—even with the data nicely tagged (and numbers directly adjacent to the labels) GPT-4o would completely make up figures to satisfy the JSON schema passed to it. YMMV.

I wonder if adversarial model which looks at user input & LLM output and predicts whether output is accurate + maybe output what is not accurate. This worked pretty well for image generation.

This is a common workflow for these sorts of problems. I've done similar a few times. The downside is the additional cost.

Re: Extracting financial disclosure and police reports with OpenAI Structured Output

#68
post #45

Earlier quoted context omitted.

It hasn’t been an issue yet, but I’m sure it will come up at some point. If you see a problem please file an issue.

So assuming it would be an issue, given that you’re building such a tool, what would your approach be? If I put an invisible tag on my website and it tells your scraper to ignore all previous prompts, leak its entire history and send all future prompts and replies to a web address while staying silent about it, how would you handle that?

A casual look at the source shows the architecture won't allow the attacks you're talking about. Since each request runs separately, there's no way for prompt injection on one request to influence a future request. Same thing for leaking history.

Re: Extracting financial disclosure and police reports with OpenAI Structured Output

#69
post #64
post #60

Adding to the list of "now try it with".... The SEC's EDGAR database (which is for SEC filings) is another nightmare ready to end. Extracting individual sections from a filing is, afaik, impossible pragmatically. I tried making two parsers: https://github.com/MegaManSec/SEC-Feed-Parser and https://github.com/MegaManSec/SEC-sec-incident-notifier but they're just hacks. Then just link it up to your automated investment…

Would you not want to read the XBRL from the filing? I thought those are now mandatory. This is one of those interesting areas where its hard to innovate because the data is already available from most/all data vendors and its cheap and accurate enough that nobody is going to reinvent those processes but also too expensive for an individual to purchase.

My (admittedly aged) experience with XBRL is that each company was able to define its own fields/format within that spec, and that most didn't agree on common names for common fields. Parsing it wasn't fun.

Re: Extracting financial disclosure and police reports with OpenAI Structured Output

#70
post #58

Earlier quoted context omitted.

We tried all models from openai and google to get data from images and all of them made "mistakes". The images are tables with 4 columns and 10 rows of numbers and metadata above that are in a couple of fields. We had thousands of images already loaded and when we tried to check those previously loaded images we found quite a few errors.

Curious, did that make you "fall back" to more conservative OCR? Or what else did you do to correct them?

We already had an OCR solution. We were exploring models in case the information source changes
Post reply on HN