Shanraq.org Shanraq.org
Let a model choose a quotation
IT

AI Engineer Lesson 3 of 4

Let a model choose a quotation

Connect a local model and trace the quote and link back to a record.

Who supplies the link?

The model receives up to three retrieved texts. It selects a source number and an exact quotation. The program supplies the address from that record. Try the protocol without downloading a model:

go test -v -run TestModelRoundTrip

A test HTTP server returns the first passage. The test checks the quote and the link to game nine. The next experiment tests whether a real model understands the question.

Ask the model

Install Ollama, then start the application or run ollama serve in another terminal. The first command downloads the model. Subsequent queries run locally.

ollama pull qwen2.5:3b
go run . -lang en ask 'How did game nine end?'
go run . -lang en serve

Open http://127.0.0.1:8091 and repeat the question. A suitable quotation gives the result of game nine and links to the English article. Compare the words with the snapshot’s body. Stop the server with Ctrl+C.

Diagnose the outcome. A selection of {"source":0,"quote":""} means insufficient evidence. If the model invents a sentence and cites the first source, verification returns an error. A connection failure means the model service could not be reached. Record a successful selection and one refusal or error. Separately judge whether the passage answers the question.

A magnifying glass over a passage in the source document.

Audio (MP3) · Project code

Transcript — The model selects a passage. The program checks the quote and supplies the address from the archive. Decide whether the passage answers the question.

If you have found a mistake or a typo in this article, tell us about it

Comments (0)

No comments yet. Be the first.