Back to the LMS journey

DecidedStop 7 of 15

Checking each claim in an AI answer against the lesson

In the LMS, a Python service called AI Core ranks lesson passages by how well they match the question. Then it checks each statement and quiz answer against them. It tells Laravel which ones the passages support.

The question

When a learner asks the LMS assistant a question, the LMS finds lesson passages related to it. Then the AI writes an answer from them. But a related passage can still disagree with what the answer says. So LMS · LMS AI Core · The AI servicePassage rankingPuts the passages Laravel sends in order, best match first. It looks at matching phrases and keywords. It also looks at each passage’s title and source.See it in the LMS build the passages and checking the answer are two separate jobs.

What made it hard

An answer is not one claim, meaning one single statement. An assistant answer has a lead, which is its opening text. After that come list items and closing text. A LMS · LMS AI Core · The Laravel sideStudy guidesA saved guide is shown only while it still matches the lesson as it is now. It must also match the current AI provider, model and settings.See it in the LMS build has a takeaway and must-know points. It also has quiz explanations and correct answers. Each of these parts needs its own check.

What I chose

Both jobs go to AI Core, the LMS’s separate Python service. First it ranks the passages. It starts from the scores that Laravel, the main LMS application, sends with them. Then it also weighs matching phrases and keywords. It weighs titles and the type of source too.

Then it LMS · LMS AI Core · The AI serviceClaim checkingSplits an answer into claims, which are single statements, and checks that the lesson supports each one. It also spots clashes in numbers, dates and names. And it spots clashes in quotes, in the order of things, and where one side says “not”.See it in the LMS build in the answer. It treats each part of the answer as a claim and scores it against the passages. The score combines shared keywords, matching runs of three characters, and comparisons between sentences.

It also looks at numbers, dates and names. It looks at quoted text and the order things come in. And it looks for negation, where one text says “not” and the other does not. Even the part that scores similar meaning is built from these rules. It is not a trained AI model. Each claim comes back with a result, its scores and the IDs of the passages that support it.

Laravel needs those IDs, because the text alone can mislead. A reply marked as weak support can still contain the answer’s original opening text. So Laravel reads the result AI Core reported, not just the text. Before it builds the learner’s reply, it checks each citation, the passage the answer names as its source. Each citation must be one of the passages that support a claim.

How I know it works

Tests cover chosen ranking cases and unsupported answers. They do not measure a general accuracy rate. A supported claim agrees with the passage it was given. That does not prove the passage is true.