Quality Issue Traceability and Defect Analysis for Active Pharmaceutical Ingredient and Pharmaceutical Intermediate Manufacturing: Knowledge Base Retrieval and Recall

Data for this category originates from multiple business systems: registered process documents, raw material batch records, DCS systems, weighing

What Data for This Category Looks Like

Data for this category originates from multiple business systems: registered process documents, raw material batch records, DCS systems, weighing systems, LIMS, chromatography data systems, and QMS. Daily documents include batch production records, material balance sheets, reaction and purification step records, cleaning validation records, impurity profile reports, deviation and change documents. Fields include batch number, reaction temperature, impurity content, solvent residue, yield data, and others. Updates occur once per production batch and per process step. Data structure adjusts dynamically based on process routes and registration requirements.

Constraints Imposed on Knowledge Base Retrieval and Recall

Multiple heterogeneous data sources require retrieval functions to support cross-system data association. This prevents incomplete traceability caused by searching only a single document type. High-frequency batch-level updates require knowledge bases to support incremental synchronization. This ensures retrieval results align with current production batch data. Specialized terminology in professional documents such as impurity profile reports and registered process documents requires retrieval to match highly relevant segments. Severe error consequences require recall results to have high confidence. This avoids deviation analysis errors caused by incorrect associations. Traceability requirements for multi-step chemical processes require retrieval results to cover full-process associated data from raw materials to finished products.

Configuration Settings

The following configurations are formulated based on the logic of FastGPT v4.17.0.

Configuration ItemRecommended SettingRationale
similarity0.75–0.85Matches the high relevance requirement for professional documents such as impurity profiles and registered processes, and avoids low-match irrelevant content from being included in retrieval results
limitTop 10 entriesCovers associated data for multi-step reactions and transfer processes, while controlling context length to avoid exceeding model limits
searchModeembeddingPrioritizes vector retrieval mode to meet matching requirements for specialized terminology and long text segments
usingReRanktruePerforms re-ranking on initial recall results to improve the accuracy of relevance ranking for long documents such as impurity profile reports and batch production records
datasetSearchUsingExtensionQuerytrueSupports extended association of multi-source business fields such as batch numbers and DCS data, meeting query requirements for full-process traceability
collectionIdsSpecify the collection ID of the target active pharmaceutical ingredient production knowledge baseIsolates knowledge base data across different categories, ensuring retrieval only covers document content for the current business scenario

Three Common Mistakes

  • When the /api/v1/chat/completions API is called with an appId, uploaded knowledge base content is not retrieved. This occurs because the collectionIds parameter is not used to specify the bound knowledge base collection ID.
  • When a similarity threshold is set, retrieval results are empty or have insufficient entries. This occurs because the threshold is set too high, filtering core documents such as impurity profile reports and batch production records that meet professional matching criteria.
  • Retrieval results fail to associate raw material batches or DCS system process data. This occurs because the datasetSearchUsingExtensionQuery extended query function is not enabled, so multi-source business fields cannot be associated.

How to Verify Correct Configuration

  • The FastGPT knowledge base list API may be called to confirm that the collection ID of the target active pharmaceutical ingredient production knowledge base matches the configured collectionIds parameter.
  • A test query such as "What is the cause of impurity exceeding standards for a batch of active pharmaceutical ingredients" may be used. Returned results may be checked to confirm that document segments such as batch production records and impurity profile reports are included.
  • The similarity threshold may be adjusted, and changes to the number of retrieval results may be observed to confirm alignment with expected behavior. Lowering the threshold increases the number of results, while raising the threshold reduces the number of results.
  • After enabling usingReRank, results ranked higher may be checked to confirm that their relevance to the test query is higher than that of initial recall results.

The values provided are common starting points and should be measured against the relevant operational samples for the specific use case.