Palantir: Building a RAG Workflow using Pipeline Builder and AIP Logic
Summary: I previously built an end-to-end RAG workflow that ingests PDFs in Foundry, transforms and chunks them in Pipeline Builder, generates embeddings for semantic search, and then exposes a retrieval function in AIP Logic. The function performs semantic search over the embeddings and uses an LLM to answer questions grounded in the source documents.
Click-path to reproduce:
- Foundry Home -> Create a new project -> Open Pipeline Builder -> + Add input -> Upload PDFs.
- Select the PDF node -> use AIP Generate to add transforms: parse text -> clean -> chunk with doc and page metadata.
- Add an embedding transform on the chunk text -> build a semantic search index -> Preview and Build the pipeline.
- Go to Apps & Logic -> AIP Logic -> New function -> add Use LLM block -> attach Semantic Search tool pointing to the embeddings/index.
- Set the system prompt to answer with citations from doc/page metadata -> Save and Publish -> Test in the Playground or a starter app.
Key definitions:
- RAG (Retrieval-Augmented Generation): An approach where an LLM retrieves relevant documents first and then generates an answer grounded in those sources.
- Embedding: A numeric vector representation of text that captures meaning; similar texts have similar vectors.
- Semantic Search: Retrieval based on meaning (via embeddings) rather than exact keyword matches.
- Chunking: Splitting long documents into smaller passages so each piece can be embedded, searched, and cited.
- Vector Index / Vector DB: A store for embeddings that enables fast nearest-neighbor lookups.
- Similarity Metric (e.g., Cosine Similarity): A score indicating how close two embeddings are; higher means more semantically similar.
- Context Window: The maximum amount of text (instructions + retrieved chunks) the model can consider at once.
- Grounding / Citations: Including retrieved passages and their sources so answers are tied to verifiable text.
- AIP Logic (Palantir): A low-code layer to wire tools (LLMs, semantic search) into callable functions or apps.
- Pipeline Builder (Palantir): A data-prep canvas to parse, clean, chunk, embed, and index documents.
- Prompt / System Prompt: Instructions to the model; the system prompt sets top-level rules and citation style.
- Hallucination (and Mitigation): When a model invents facts; mitigated by good retrieval, strict prompting, and requiring citations.
RAG App using GitHub Repo as Datasource
RAG app via third-party platform: I delivered a production-ready Retrieval-Augmented Generation (RAG) application by orchestrating a third-party AI platform (connectors, embeddings, vector search, simple UI) with OpenAI's ChatGPT API for generation. Users ask natural-language questions about my GitHub project; the app retrieves relevant repo content and produces grounded answers with citations back to specific files or lines.
What "RAG" means: RAG is an LLM pattern where the app first retrieves relevant text from a knowledge base and then generates the answer using those passages as context. This reduces hallucinations and keeps answers current without retraining the model.
My implementation:
- Third-party platform setup: Configured a GitHub connector to sync the repo; enabled automatic parsing, chunking, and metadata capture (file path, language, line ranges, commit hash).
- Embeddings and index: Used the platform's embedding service and vector index; tuned chunk size/overlap and added path or file-type filters.
- Query pipeline: User question → embed query → semantic search (top-k) → optional rerank → platform composes prompt with retrieved passages → calls OpenAI ChatGPT API → UI renders answer with citations.
- Guardrails and ops: Citation-required prompting, max-context limits, API usage/rate-limit handling, scheduled re-index on repo changes, and retrieval hit/miss logging.
Impact: Reduced unsupported claims via source-grounding with citations; delivered interactive answers in seconds versus manual repo search; indexed all targeted code and docs with filterable scope.
Outcomes
- Integrated a third-party AI platform with OpenAI's ChatGPT API to deliver a RAG app over my GitHub repository, enabling natural-language queries with line-level citations.
- Owned the end-to-end retrieval stack (repo sync, parsing and chunking, embeddings, semantic search, reranking) and implemented citation-required prompts for grounded answers.
- Operationalized re-indexing, evaluation questions, and observability for retrieval hit rate, latency, and answer faithfulness.
Architecture:
- Ingest (third-party): GitHub connector → parse → chunk → attach metadata.
- Index (third-party): Embed chunks → upsert to vector index with filters.
- Retrieve (third-party): Embed query → vector search (top-k) → optional rerank.
- Generate (OpenAI API): Third-party app assembles prompt with retrieved context → calls ChatGPT → returns answer with citations.
- Observe (third-party): Logs and dashboards.
Key terms:
- Embedding: Numeric vector representing meaning; similar text → nearby vectors.
- Semantic search: Retrieval by meaning (via embeddings), not just keywords.
- Chunking: Splitting files into smaller passages so retrieval and context windows work well.
- Top-k / Rerank: Select the best k passages; reranking re-orders with a more precise model.
- Context window: The maximum text the model reads at once (instructions plus retrieved chunks).
- Grounding and citations: Answers reference retrieved sources to remain verifiable and reduce hallucinations.
Tech choices: Third-party platform for data connectors, embeddings, vector index, and UI; OpenAI API (ChatGPT and embeddings) for language understanding and generation; scheduled re-index on repo updates and a lightweight evaluation set with expected file hits.
Evaluation and quality: Curated "golden" questions mapped to expected files and tracked retrieval, answer faithfulness and whether cited sources matched what the model read.
Security and privacy: Scoped API keys, repository/path whitelists, sanitized prompts, response restriction to retrieved context, and minimal analytics logging.
RAG Implementation
Content retrieval and AI retrieval are different
The portfolio’s original frontend loaded an Excel workbook and selected HTML snippets to present professional experience. That was a structured content system, rather than retrieval-augmented generation by itself.
The portfolio today
Content is assembled into static pages during publishing. Search filters the published collection in the browser. Neither operation requires a language model.
Where RAG applies
A RAG application retrieves relevant passages from a knowledge source and gives those passages to a language model to support an answer. My separate repository-based implementation uses a third-party AI platform to connect retrieval, generation, and citations.