-
Notifications
You must be signed in to change notification settings - Fork 3
Support for LLM backend: implementation plan #21
Description
Hi,
our team at @NatLibFi has been looking at performing metadata extraction using large language models. Since our initial experiments have been promising, we would like to move towards a prototype system that could be used for demonstrations. Since Meteor already provides the basic building blocks (API, web UI, backend code that uses extraction heuristics...) we would like to extend the codebase with another backend that uses a LLM for the extraction part. We are going to develop this in a fork of this repo, https://github.com/NatLibFi/meteor and if you're interested, we could contribute the code back to this upstream repository sometime in the future (for now this would obviously be just a prototype).
This is the initial implementation plan:
Minimal LLM support for Meteor
Configuration:
- env var LLM_API_URL + optional LLM_API_KEY
- prompt template set inside LLMExtractor for now but should be configurable in the future
- could be a template file chosen by LLM_PROMPT_TEMPLATE env var
Changes to Meteor class
- run method: if LLMExtractor.is_available(), run LLMExtractor instead of Finder
Changes to MeteorDocument class
- add support for extracting text for use by LLM
New LLMExtractor class
- similar to Finder
- is_available() returns True if LLM_API_URL is set
- essential functionality:
- request text from MeteorDocument
- build prompt using template + text
- send request to LLM service (request JSON if possible?)
- parse response
- return extracted metadata
Do you think the above implementation plan sounds reasonable? It would result in an experimental version of Meteor that selects the extraction method (heuristics or LLM) at runtime based on the presence (or not) of an environment variable. This way the "traditional" Meteor approach can be compared head-to-head with the LLM version in terms of extraction quality, response time, resource usage etc. The LLM itself would be hosted as an external inference service (e.g. vLLM) used via API calls. In the initial version, we would stick to the metadata fields currently supported by Meteor, but in the future we would like to expand this to more fields, as the LLM approach allows adding more fields quite easily.
We are still working on prototyping the LLM based extraction techniques and fine-tuning local LLM models in the https://github.com/NatLibFi/FinGreyLit repository, in particular the experiments directory. It will take a while to set this up and start coding. I opened this issue to make you aware of our plans and potentially get feedback on what would make sense from your perspective.