{"id":29129000,"url":"https://github.com/nico-martin/ask-my-pdf","last_synced_at":"2025-06-30T02:37:44.387Z","repository":{"id":239663823,"uuid":"791203514","full_name":"nico-martin/ask-my-pdf","owner":"nico-martin","description":"A Webapp that uses Retrieval Augmented Generation (RAG) and Large Language Models to interact with a PDF directly in the browser.","archived":false,"fork":false,"pushed_at":"2024-11-17T15:55:10.000Z","size":1501,"stargazers_count":58,"open_issues_count":4,"forks_count":5,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-11-17T16:44:18.539Z","etag":null,"topics":["rag","transformers-js","webai","webllm"],"latest_commit_sha":null,"homepage":"https://pdf.nico.dev","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/nico-martin.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-04-24T09:28:26.000Z","updated_at":"2024-11-15T00:29:50.000Z","dependencies_parsed_at":"2024-05-13T23:25:40.119Z","dependency_job_id":"81e87675-c9a5-4827-a265-d186b6653923","html_url":"https://github.com/nico-martin/ask-my-pdf","commit_stats":null,"previous_names":["nico-martin/ask-my-pdf"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/nico-martin/ask-my-pdf","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nico-martin%2Fask-my-pdf","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nico-martin%2Fask-my-pdf/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nico-martin%2Fask-my-pdf/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nico-martin%2Fask-my-pdf/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nico-martin","download_url":"https://codeload.github.com/nico-martin/ask-my-pdf/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nico-martin%2Fask-my-pdf/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":262700269,"owners_count":23350444,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["rag","transformers-js","webai","webllm"],"created_at":"2025-06-30T02:37:43.834Z","updated_at":"2025-06-30T02:37:44.375Z","avatar_url":"https://github.com/nico-martin.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"![Ask my PDF](https://pdf.nico.dev/twitter.jpg)\n\n# Ask my PDF\n\nA Webapp that uses Retrieval Augmented Generation (RAG) and Large Language Models to interact with a PDF directly in the browser.\n\n[pdf.nico.dev](https://pdf.nico.dev)\n\nThere are three main pillars this tool is based on:\n\n## 1. Read the PDF\n\n**Ask my PDF** uses [PDF.js](https://www.npmjs.com/package/pdfjs-dist) to process a PDF locally and split the content up into separate lines.\n\n## 2. Vector Search\n\nIndividual paragraphs and then sentences are extracted from the document and will be mapped to a multi-dimensional dense vector space using [all-MiniLM-L6-v2](https://huggingface.co/sentence-transformers/all-MiniLM-L6-v2) with [TransformersJS](https://github.com/xenova/transformers.js). Those entries are then stored in an in-memory [VectorDB](https://gist.github.com/nico-martin/64f2ae35ed9a0f890ef50c8d119a6222) directly in the browser.\n\nAs soon as a query is submitted, it is also vectorized and the cosine similarity search is used to find the most similar text sections, together with the lines surrounding them, so as not to lose the context.\n\n## 3. LLM answer generation\n\nThe text sections found this way together with the query and a few instructions are then used as the input prompt to the [Gemma2-2B](https://huggingface.co/google/gemma-2-2b) or [Gemma2-9B](https://huggingface.co/google/gemma-2-9b), compiled to WebAssembly and WebGPU using [MLC LLM](https://llm.mlc.ai/), which will then generate a response.  \nIf available, also the [Prompt API](https://github.com/explainers-by-googlers/prompt-api) can be used to generate text. The Prompt API is an experimental project by Google Chrome, so it is only available in a few browsers yet.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnico-martin%2Fask-my-pdf","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnico-martin%2Fask-my-pdf","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnico-martin%2Fask-my-pdf/lists"}