LESSON 74 · REAL-WORLD PROJECTS

Company Knowledge Assistant

Build an internal AI assistant that answers employee questions from trusted company knowledge using RAG, permission-aware retrieval, citations, and production monitoring.

30 min read•Intermediate•Python•RAG Project

How a Company Knowledge Assistant Works

SourcesPolicies + docs
IngestExtract + clean
ChunkSplit knowledge
IndexEmbeddings + metadata
RetrieveFilter + rerank
AnswerGrounded + cited
iCore idea: the assistant should treat company sources as the knowledge system. The model generates the response, but retrieved and authorized evidence should support important claims.
1

What Are We Building?

Build an internal AI assistant that answers employee questions using company documents, policies, product information, and knowledge bases. The assistant should retrieve relevant company knowledge before generating an answer.

Employee experience

Ask a natural-language question and receive a concise answer with supporting sources.

Admin experience

Control sources, permissions, freshness, evaluation, and feedback.

2

Understand the Architecture

A practical architecture separates ingestion from question answering: documents are collected and indexed once, while employee questions trigger retrieval and generation.

SourcesApproved content
IngestionParse + chunk
IndexVectors + metadata
QueryRetrieve + filter
AnswerGround + cite
3

Connect Company Knowledge Sources

Typical sources include PDFs, DOCX files, web pages, help-center articles, Notion pages, wikis, tickets, and structured databases. Each source should have an owner and update strategy.

4

Ingest Documents

The ingestion pipeline loads source content, extracts text, preserves metadata, cleans noise, chunks the content, creates embeddings, and stores searchable records.

5

Preserve Metadata

Keep document ID, title, department, source URL, access group, section, timestamps, and version information. Metadata becomes important for filtering, citations, and permissions.

6

Chunk Company Knowledge

Good chunks preserve a coherent policy, procedure, product explanation, or section. Avoid chunks that mix unrelated departments or topics.

7

Create Embeddings

Embeddings turn chunks into vectors so a question such as “How many days can I work remotely?” can retrieve semantically related policy text even when the wording differs.

</> Python
from dataclasses import dataclass

@dataclass
class CompanyChunk:
    text: str
    document_id: str
    department: str
    access_group: str

chunk = CompanyChunk(
    text="Employees receive 20 paid vacation days.",
    document_id="hr-policy-2026",
    department="hr",
    access_group="employees",
)

print(chunk.document_id, chunk.department)
8

Store the Knowledge Index

Use a vector database or search index to store embeddings, text, and metadata. Keep the original source reference so answers can show where information came from.

9

Retrieve Relevant Knowledge

At query time, embed the employee question, retrieve candidate chunks, apply metadata and permission filters, and optionally rerank the candidates before generation.

10

Apply Access Control

Retrieval must respect the employee’s permissions. A user should never receive retrieved text from a private HR, finance, legal, or executive document they are not authorized to access.

Security rule: apply authorization before the model receives retrieved content, not after the answer has already been generated.
11

Build a Grounded Prompt

Give the model only the selected company context and clear instructions to answer from that context. If the evidence is insufficient, the assistant should say that it cannot verify the answer.

</> Python
def build_grounded_prompt(question: str, contexts: list[str]) -> str:
    evidence = "\n\n".join(contexts)
    return f"""Answer using only the company evidence below.
If the evidence is insufficient, say you cannot verify the answer.

Evidence:
{evidence}

Question: {question}"""

prompt = build_grounded_prompt(
    "How many vacation days do employees receive?",
    ["HR policy: Employees receive 20 paid vacation days."],
)
print(prompt)
12

Return Sources and Citations

Show document titles, sections, page numbers, or links where possible. Citations let employees verify important answers and help administrators debug retrieval.

13

Handle Unknown Questions

Do not force an answer. If retrieval confidence is low or the context does not support the question, route to a human, ask for clarification, or state that the knowledge base does not contain enough information.

14

Keep Knowledge Fresh

Company information changes. Track document versions, update timestamps, ingestion status, and deletion events. Re-index changed content instead of blindly creating duplicates.

  • Track source version
  • Record updated timestamp
  • Remove deleted content
  • Re-index changed documents
15

Combine RAG with Tools

Use RAG for knowledge and tools for live actions. For example, retrieve the leave policy with RAG, then call an HR system to check an employee’s remaining leave balance.

16

Monitor the Assistant

Track retrieval quality, answer quality, latency, token usage, citations, failed searches, permission denials, and user feedback.

</> Python
def can_access(user_groups: set[str], required_group: str) -> bool:
    return required_group in user_groups

user_groups = {"employees", "engineering"}
print(can_access(user_groups, "employees"))
print(can_access(user_groups, "executives"))
17

Evaluate with Real Questions

Create a representative evaluation set from real employee questions. Measure retrieval relevance, groundedness, citation correctness, refusal behavior, and answer usefulness.

18

Secure the Knowledge Base

Protect source documents, embeddings, credentials, logs, and prompts. Treat retrieved company data as sensitive application data and apply least-privilege access.

IdentityAuthenticate every user.
AuthorizationFilter by access groups.
DataProtect documents and logs.
19

Build the Company Knowledge Assistant

A useful first version can support one department, a small document set, citations, access filters, feedback buttons, and an escalation path. Expand after measuring quality.

20

Common Mistakes

Indexing everything without ownership, ignoring permissions, returning uncited answers, using stale documents, retrieving too much context, and treating the LLM as the source of truth are common production mistakes.

21

Mini Project: Internal Support Assistant

Create an assistant for HR or IT. Index approved documents, attach metadata, filter by employee access, retrieve the top candidates, generate a grounded answer, and return citations plus a “contact support” fallback.

22

30-Second Recap

Company Knowledge Assistant = trusted sources + ingestion + chunking + embeddings + retrieval + permission filtering + grounded generation + citations + monitoring.

23

Key Takeaways

Treat company knowledge as a governed data system. Retrieval should be permission-aware, answers should be grounded and cited, and freshness and evaluation must be part of the design.

Quick Check

1. What should the assistant do when the knowledge base cannot verify an answer?

A. Guess confidently B. Say it cannot verify the answer or escalate C. Invent a policy D. Ignore retrieval

2. Why is permission-aware retrieval important?

A. It makes embeddings smaller B. It prevents users from receiving unauthorized company information C. It removes the need for authentication D. It increases model temperature

3. What should be returned with important answers?

A. Only a confidence score B. Source references or citations C. The full database D. Hidden prompts

Key Takeaways

  • Use trusted company sources as the foundation for answers.
  • Make retrieval permission-aware before sending context to the model.
  • Return citations so employees can verify important information.
  • Track freshness, retrieval quality, groundedness, latency, and feedback.