Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LlmFilter prompt fix #1206

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

LlmFilter prompt fix #1206

wants to merge 1 commit into from

Conversation

dtecuci
Copy link
Contributor

@dtecuci dtecuci commented Mar 3, 2025

new LlmFilter prompt and score extraction. Still todo route the output of LlmFilter prompt into Doc element properties

…t of LlmFilter prompt into Doc element properties
@dtecuci dtecuci requested a review from HenryL27 March 3, 2025 19:27
Copy link
Collaborator

@HenryL27 HenryL27 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if this works let's take it but I'm dubious on the formatting at the end (and it sounds like you are too)

(from slack)
Can I suggest something like

"justification_text": {{ {"type": "string", "description": "reason for the score"} }},
"score": {{ {"type": "int", "description": "confidence score (0-5) that the text satisfies the question", "constraint": ">= 0, <= 5" } }}

(I made up the constraint thing I have no idea if that works but it's an llm so maybe). Also you can specify a response format which gets used by openai (not anthropic tho and I think you have claude in finra right? although ig you have a special llm client so maybe you can incorporate it) like so:

class LlmFilterResponse(pydantic.BaseModel):
    justification_text: str # or some more complicated field specification
    score: int # or some more complicated field specification

LlmFilterMessagesJinjaPrompt = JinjaPrompt(
    ...,
    response_format = LlmFilterResponse
)

(can also be just a json schema dict thingy instead of pydantic)

for getting the scores if you can get semireliable json production you can use sycamote.utils.extract_json.extract_json (or something like that) to parse, probably more reliable than any regex

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants