{"id":14064931,"url":"https://github.com/Cutwell/ollama-langchain-guide","last_synced_at":"2025-07-29T19:31:59.811Z","repository":{"id":223764410,"uuid":"760702625","full_name":"Cutwell/ollama-langchain-guide","owner":"Cutwell","description":"Develop LangChain using local LLMs with Ollama","archived":false,"fork":false,"pushed_at":"2024-05-21T07:44:04.000Z","size":257,"stargazers_count":1,"open_issues_count":2,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-10-31T18:51:32.913Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","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/Cutwell.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-02-20T19:26:19.000Z","updated_at":"2024-06-24T01:28:06.000Z","dependencies_parsed_at":"2024-04-18T17:36:06.843Z","dependency_job_id":null,"html_url":"https://github.com/Cutwell/ollama-langchain-guide","commit_stats":null,"previous_names":["cutwell/ollama-langchain-guide"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Cutwell%2Follama-langchain-guide","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Cutwell%2Follama-langchain-guide/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Cutwell%2Follama-langchain-guide/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Cutwell%2Follama-langchain-guide/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Cutwell","download_url":"https://codeload.github.com/Cutwell/ollama-langchain-guide/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":228040900,"owners_count":17860212,"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":[],"created_at":"2024-08-13T07:04:11.101Z","updated_at":"2024-12-04T03:31:44.880Z","avatar_url":"https://github.com/Cutwell.png","language":"Python","funding_links":[],"categories":["Python"],"sub_categories":[],"readme":"# \u003cimg src=\"resources/ollama.png\" style=\"height:32px;margin-bottom:-8px;\"\u003e + \u003cimg src=\"ollama_langchain_guide/src/phi.svg\" style=\"height:32px;margin-bottom:-8px;\"\u003e ⇨ \u003cimg src=\"resources/langchain.png\" style=\"height:32px;padding-right:20px;margin-bottom:-8px;\"\u003e Ollama LangChain Guide\n Develop LangChain using local LLMs with Ollama\n\n* LLM costs getting you down?\n* Want to develop offline?\n* Don't want to share your personal data with LLM providers?\n* Save costs, develop anywhere, and own all your data with Ollama and LangChain!\n\n## Before you start\n\n* This tutorial requires several terminals to be open and running proccesses at once i.e.: to run various Ollama servers.\n* When you see the 🆕 emoji before a set of terminal commands, open a new terminal process.\n* When you see the ♻️ emoji before a set of terminal commands, you can re-use the same terminal you used last time.\n\n## Prerequisites\n\n1. Download and install [Ollama](https://ollama.com/download) and start the server.\n\n🆕\n```sh\ncurl -fsSL https://ollama.com/install.sh | sh\nollama serve\n```\n\n2. Download and install [Poetry](https://python-poetry.org/docs/#installing-with-the-official-installer).\n\n3. Fork this repository and setup the Poetry environment:\n\n🆕\n```sh\ngit clone https://github.com/Cutwell/ollama-langchain-guide.git\ncd ollama-langchain-guide\npoetry install\n```\n\n## Tutorial\n\n1. Browse the [available Ollama models](https://ollama.com/library) and select a model.\n\n* Think about your local computers available RAM and GPU memory when picking the model + quantisation level.\n* We will be using the `phi-2` model from Microsoft ([Ollama](https://ollama.com/library/phi), [Hugging Face](https://huggingface.co/microsoft/phi-2)) as it is both small and fast.\n* Read [this](https://www.promptingguide.ai/models/phi-2) summary for advice on prompting the `phi-2` model optimally.\n\n♻️\n```sh\nollama pull phi\n```\n\n2. Start the Ollama server.\n\n* This server can be queried with LangChain, or you can interact with it in this terminal.\n\n♻️\n```sh\nollama run phi\n```\n\n3. Run the PyTest tests in `/ollama_langchain_guide/tests` to check everything is working correctly.\n\n🆕\n```sh\npoetry run pytest -rP ollama_langchain_guide/tests\n```\n\n4. Get started building your own local LLM projects with the example StreamLit app in `/ollama_langchain_guide/src`.\n\n♻️\n```sh\npoetry run streamlit run ollama_langchain_guide/src/app.py --server.port=8080\n```\n\n## Pros and Cons of Phi-2\n\n|**Pros**|**Cons**|\n|:---:|:---:|\n|Natural language, human-like outputs.|Can distract itself, prone to creating logic puzzles based on user queries + tries to solve them itself.|\n|Context window of 2048 tokens - can use chat history in answers.|Often ignores established facts in chat history - answers same question multiple ways in the same conversation.|\n|Can output syntax-correct Python code.|Bad at generating code that achieves desired goal - e.g.: outputs a syntax-correct function to calculate Pi, but the outputs are garbage.|\n|Very fast response time.||\n\n## License\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FCutwell%2Follama-langchain-guide","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FCutwell%2Follama-langchain-guide","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FCutwell%2Follama-langchain-guide/lists"}