Agent Application DevelopmentAccount
Knowledge catalogChoose core direction and segmented content
knowledge unit 24IntermediateImplementationAbout 12 minutes

Understand → Implement → Debug → Design

Entity disambiguation and constraint preservation in query rewriting

Examining multiple rounds of reference, entity linking, clarification, and original constraint preservation.

Query rewritingentity linkMultiple rounds of dialogue

Knowledge content check2026-10-03 · Check the source of the original question2026-10-02

Which step do you want to learn from this knowledge point?

Select the starting point based on the current basis, or you can go deeper one by one. When you encounter an unfamiliar concept, go back to the core principles first; use the knowledge exercises to check your understanding when you are finished.

Understand first

New to this knowledge point

Complete the prerequisite concepts, read the principles and counterexamples, and then explain why in your own words.

Start with core principles →

Realize again

Prepare to write the principles into code

Understand implementation steps and boundaries, complete small tasks, and check results against acceptance requirements.

Reading implementation and trade-offs →

Will troubleshoot

Need to handle failures and changes in conditions

Follow the continuous questioning to locate the failure premise, and then compare the migration cases to explain how the plan should be adjusted.

Continue to delve deeper into the problem →

Able to choose

Need to design or review plans

Combine engineering deductions and senior self-evaluation standards to explain the applicable conditions, costs and alternatives of the plan.

Analyze engineering scenarios →
Knowledge unit directory

LEARN · PRACTICE · REFLECT

Knowledge learning and personal records

My notes and review ↗

First read along the principles, Q&A and migration cases. When you need to check your understanding, switch to reinforcement exercises or start personal recording.

Answers and personal notes

Each modified commit will be kept as an independent history. Your level of mastery is up to you to evaluate yourself against the standards.

Core concept · Entity disambiguation and constraint preservation in query rewriting

Understand the core principles first

Preparatory concepts:Conversation state and deference, Structured query slot, Clarification and search planning

The purpose of rewriting is to express the known intention more retrievably and not to create missing facts. Entity, negation, time, and scope must have a source, and ambiguities affecting the answer need to be preserved or clarified.

Resolve references through constrained state

“What is its balance in Chongqing?” depends on earlier context without naming a complete entity. Record candidate entities, the source turn, and actual user confirmations. Keep confirmed entities separate from guesses. Similarity is neither authorization nor confirmation.

Preserve the original and protected intent fields

Structured intent distinguishes entity, region, metric, time, and exclusions; unknowns remain unknown. Original and expanded search branches share one trusted access scope. Compare identifiers, negations, and dates before and after rewriting. Reintroducing a frequent historical entity after “not China Merchants Bank, ICBC” corrupts intent rather than merely degrading retrieval.

Clarify when ambiguity changes the result

Ask the most discriminating concrete question when candidates imply different answers. Low-risk searches can retrieve alternatives and show differences, but cannot silently merge them. Financial, authorization, and action requests need clearer definitions. Clarification depends on consequence, not a mechanical similarity-gap threshold.

Test fidelity with counterfactual pairs

Change only negation, region, date, or account scope and verify only that field changes. Evaluate original question, structured intent, and final answer separately with traceable evidence. Retain current confirmations and exclusions as history grows. A new statement can correct prior context, but saying something yesterday does not establish that the fact only becomes effective today.

Check understanding with a question

The user only asks "Where is its balance in Chongqing?" How to rewrite the query without making up the intention?

Resolve references from current context, preserving the original question and evidence for each entity. Clarify competing entities or missing conditions that change the answer. Rewriting cannot invent banks, dates, account scope, or authorization. Evaluate original and rewritten intent for preserved negation, scope, and time constraints.

Realization and trade-offs

Rewriting requires traceable input

The context selects the most recently explicitly confirmed subject, user modifier, and current task target without flooding the rewriter with full chat. Output entity ID candidates, regions, indicators, time ranges, evidence locations, and fields to be clarified. Trusted identities and visible data scopes are appended by the server. The rewriter can only select authorized candidates and cannot generate new authorization scopes.

Separate reference and entity linking

"It" may be China Merchants Bank from the previous round, or it may be a specific account. The referent is resolved first and then mapped to the bank, branch or account in the data dictionary. Similar names do not represent the same entity. Candidates should contain distinguishable regional and organizational attributes. Automatically select only when the current context is clear enough, otherwise use short questions to confirm instead of always selecting the candidate with the highest similarity.

Rewriting cannot change task constraints

Restrictions such as "excluding frozen funds", "yesterday's closing" and "this department only" are retained. Synonyms can be expanded for retrieval, but balance inquiries cannot be turned into expenditure inquiries, nor can "Chongqing Branch" be expanded to include all accounts in Chongqing. Multiple query variants need to share the budget and return to the original definition in the final answer to avoid finding different objects separately and then splicing them together.

Evaluation error propagation

Construct multiple rounds of dialogue and deliberately add entity switching, negative corrections, branches with the same name, and historical expiration information. Measure entity accuracy, constraint retention rate, incorrect automatic selection rate, and completion rate after clarification respectively. Only by retaining the original question, rewriting, and entity candidates when retrieving the final wrong answer can we determine that the question comes from rewriting rather than incorrectly adjusting the Embedding parameters.

Engineering deduction

scene
Interview hypothesis: In the last round of comparing China Merchants Bank and Industrial Bank, the user continued to ask "its balance in Chongqing".
design decisions
Identify ambiguities in references, list authorization candidates, and clarify bank and account scope.
Verify target
After confirmation, query according to the correct range, and the rewrite chain can be used to locate errors.
applicable boundary
Historical user preferences cannot be used to replace key entities that are missing from the current problem.

Continuous questions and answers

Continue reading along with the premises and constraints of the problem. Understand the reference answers first, then try to put away the answers and explain the cause and effect and trade-offs in your own words.

Draw inferences from one example: If the conditions change, how to deduce it?

First find out the conditions for change, and then determine which premises in the original plan still hold true. The following cases are teaching deductions to facilitate the transfer of principles to new problems.

Low-risk technical information search

Changing conditions:Results are used for browsing rather than financial judgment

Extended question:"How to write its cancellation" exists in two libraries. Can I ask one less question?

Derivation and reference solutions

You can return a short description and source of two candidate libraries for the user to select, or give priority to the library if there is a confirmed context. The retrieval plan still separates versions and entities, and you cannot match A's cancellation API with B's sample code. Update session state based on user selections, retaining current hypothesis labels.

The principles that remain unchanged:Allowing exploration does not mean allowing secret confirmation. The evidence must correspond to each candidate explanation.

User has multiple projects

Changing conditions:The same technology name has been mentioned in history, but the current project is different

Extended question:Is it advisable to override the most recent project configuration?

Derivation and reference solutions

The currently explicitly selected project scope is used first before its confirmed configuration is read; another project mentioned in the most recent round may just be the comparison object. Clarification when scope is missing and version affects answer. Permission boundaries are obtained from the server. Just because a project is mentioned in history, it cannot be considered that it is still readable.

The principles that remain unchanged:Session dependencies are not equal to the current object and access grants, intents must be resolved within an explicit scope.

Easy to make mistakes

  • The one with the highest similarity will be automatically selected.
  • Rewrite and delete negative words
  • Retrieval failure all attribution vector models

References

It is designed based on public technical information; the reference materials support the technical mechanism, and the scenarios and scoring standards are designed by this website and do not represent the original interview questions of a certain company. New Q&A and migration cases are added for principle explanation, and source verification and case operation verification are recorded separately.

Check how far you understand

After reading, you can explain the principles, boundaries, and trade-offs against these standards. It is up to you to evaluate your mastery; if further verification is needed, complete the small tasks below.

Basic standards met
Can parse reference in the current conversation and retain the original question for verification.
Intermediate and advanced signals
Structured output of candidate, constraint and clarification fields.
Senior Signal
Able to hierarchically evaluate error propagation and automatically select risks.

Hands-on verificationComplete on demand · Suggestions15 minutes

Rewrite the three rounds of dialogue with subject switching into structured intentions, and mark the fields that cannot be automatically determined.

Expand acceptance requirements and checkpoints
  • Don't make up missing subjects
  • Preserve negation and time range
  • Clarification questions ask only key ambiguities

Key inspections

  • Reference and entity mapping layering
  • Original constraints and modifications retained
  • There are clear clarification conditions