Quality Issue Traceability and Defect Analysis for Pharmaceutical Preparations Production: Knowledge Base Retrieval and Recall

Data sources for pharmaceutical preparations production include approved formulation processes, MES electronic batch records, equipment and

What the data for this category looks like

Data sources for pharmaceutical preparations production include approved formulation processes, MES electronic batch records, equipment and environmental monitoring data, LIMS test records, deviation and CAPA documents from quality management systems, and other relevant sources. Data is updated per production batch, each key process step, and according to fixed monitoring plans. Daily documents include master production documents, batch production records, cleaning records, batch release audit forms, and other relevant materials. Fields cover material batch numbers, process parameter values, test results, deviation descriptions, and other relevant details. Units include professional metering identifiers such as grams (g), degrees Celsius (℃), hours (h), and other industry-standard measurement labels.

Data is associated by production batch and updated frequently. Retrieval must limit results to the current batch’s document scope to avoid interference from irrelevant cross-batch data. Documents contain structured fields and unstructured text. Hybrid retrieval must balance keyword matching and vector similarity to accurately match process parameters and deviation descriptions. GMP requirements mandate data synchronization with production operations. Recall result timeliness must match the production site’s response pace. Professional formulas and metering identifiers in documents must be retained to ensure quality analysis accuracy. Batch record content is lengthy. Retrieval result text length must be controlled to avoid exceeding model input context limits.

How to set up the configuration

This configuration is based on FastGPT v4.17.0.

Configuration ItemRecommended SettingRationale
similarity0.75–0.85Process parameters and test results for pharmaceutical preparations require high matching accuracy to avoid recalling low-relevance content
limitTop 8–12 entriesControl the total character count of retrieval results to no more than 2000 characters, complying with the context limit of model inputs
searchModemixedRecallBalance keyword matching for structured batch numbers and vector similarity matching for unstructured process text
usingReRankEnabledRe-rank results from hybrid retrieval to improve the ranking priority of high-match content and reduce false recalls
datasetSearchUsingExtensionQueryEnabledPerform extended queries on simplified descriptions of production issues to match complete process documents and batch record content
collectionIdsSpecify the knowledge base collection associated with the current production batchOnly recall documents corresponding to the current batch. Designate database columns such as batch numbers and process parameters as index fields to narrow the retrieval scope

Three common misconfigurations

  • Symptom: Retrieval returns document content unrelated to the current batch’s quality issue. Cause: Failed to limit the knowledge base collection to the current batch via collectionIds, or set the similarity threshold too low, resulting in irrelevant data being recalled.
  • Symptom: Chemical metering formulas in the knowledge base fail to display properly or are truncated. Cause: Formulas in documents are not embedded in standard LaTeX format, and chunking configuration fails to retain the complete structure of formulas, leading to loss of formula information during retrieval.
  • Symptom: Inconsistent return results for the same retrieval request when deploying the model locally. Cause: Failed to fix the similarity threshold, or failed to enable usingReRank, leading to random fluctuations in the ranking and matching degree of recall results.

How to confirm the configuration is correct

  • Retrieve quality deviation issues for a specified batch, and verify that recall results only include batch production records, test records, and deviation documents for that batch.
  • Input a query containing a chemical ratio formula, and verify that the complete formula content is correctly displayed in the recalled documents.
  • Submit the same retrieval request multiple times, and verify that the number of returned results and similarity distribution remain consistent.
  • Check the retrieval logs to confirm that only the knowledge base collection associated with the current batch was called, and no irrelevant documents were retrieved across batches.

The values provided are common starting points and should be measured against the reader's own samples.