ScholarLens
VSCode 本地科研助手 - 语义检索、引用推荐、RAG 文献对话
核心理念:Zotero for Management, VSCode for Thinking
功能特性
- 语义检索:基于向量数据库的文献片段检索
- 引用推荐:写作时根据上下文自动推荐相关文献(
@ 触发补全)
- RAG 文献对话:侧边栏对话界面,基于文献库进行问答
前置要求
Ollama:本地运行 Ollama,并拉取以下模型:
- Embedding:
ollama pull nomic-embed-text
- Chat:
ollama pull llama3
Zotero + Better BibTeX:配置自动导出 mylibrary.bib,确保 bib 条目包含 file 字段(PDF 路径)
安装
- 克隆或下载本仓库
- 在项目目录运行
npm install && npm run compile
- 在 VSCode 中按 F5 启动扩展开发主机,或打包为 .vsix 安装
配置
在 VSCode 设置中配置:
| 配置项 |
说明 |
默认值 |
scholarlens.bibFilePath |
library.bib 的绝对路径 |
空 |
scholarlens.ollamaBaseUrl |
Ollama API 地址 |
http://localhost:11434 |
scholarlens.embeddingModel |
Embedding 模型 |
nomic-embed-text |
scholarlens.chatModel |
Chat 模型 |
llama3 |
scholarlens.topK |
检索返回数量 |
5 |
使用流程
- 配置 bib 路径:设置 → ScholarLens → bibFilePath
- 索引文献库:命令面板 →
ScholarLens: Index Library(首次较慢)
- 写作引用:
- 在 Markdown/LaTeX 中输入
@ 触发补全
- 或使用快捷键
Ctrl+Shift+C (Mac: Cmd+Shift+C) 打开引用选择
- 文献对话:点击左侧 ScholarLens 图标,在「文献对话」面板提问
技术栈
- VSCode Extension API
- LanceDB(向量数据库)
- Ollama(本地 LLM + Embeddings)
- pdf-parse(PDF 解析)
- bibtex-parse(BibTeX 解析)
开发
npm install
npm run compile
# F5 启动调试
License
ISC
| |