lancedb.mdx 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. ---
  2. title: LanceDB
  3. ---
  4. ## Install Embedchain with LanceDB
  5. Install Embedchain, LanceDB and related dependencies using the following command:
  6. ```bash
  7. pip install "embedchain[lancedb]"
  8. ```
  9. LanceDB is a developer-friendly, open source database for AI. From hyper scalable vector search and advanced retrieval for RAG, to streaming training data and interactive exploration of large scale AI datasets.
  10. In order to use LanceDB as vector database, not need to set any key for local use.
  11. ### With OPENAI
  12. <CodeGroup>
  13. ```python main.py
  14. import os
  15. from embedchain import App
  16. # set OPENAI_API_KEY as env variable
  17. os.environ["OPENAI_API_KEY"] = "sk-xxx"
  18. # create Embedchain App and set config
  19. app = App.from_config(config={
  20. "vectordb": {
  21. "provider": "lancedb",
  22. "config": {
  23. "collection_name": "lancedb-index"
  24. }
  25. }
  26. }
  27. )
  28. # add data source and start query in
  29. app.add("https://www.forbes.com/profile/elon-musk")
  30. # query continuously
  31. while(True):
  32. question = input("Enter question: ")
  33. if question in ['q', 'exit', 'quit']:
  34. break
  35. answer = app.query(question)
  36. print(answer)
  37. ```
  38. </CodeGroup>
  39. ### With Local LLM
  40. <CodeGroup>
  41. ```python main.py
  42. from embedchain import Pipeline as App
  43. # config for Embedchain App
  44. config = {
  45. 'llm': {
  46. 'provider': 'huggingface',
  47. 'config': {
  48. 'model': 'mistralai/Mistral-7B-v0.1',
  49. 'temperature': 0.1,
  50. 'max_tokens': 250,
  51. 'top_p': 0.1,
  52. 'stream': True
  53. }
  54. },
  55. 'embedder': {
  56. 'provider': 'huggingface',
  57. 'config': {
  58. 'model': 'sentence-transformers/all-mpnet-base-v2'
  59. }
  60. },
  61. 'vectordb': {
  62. 'provider': 'lancedb',
  63. 'config': {
  64. 'collection_name': 'lancedb-index'
  65. }
  66. }
  67. }
  68. app = App.from_config(config=config)
  69. # add data source and start query in
  70. app.add("https://www.tesla.com/ns_videos/2022-tesla-impact-report.pdf")
  71. # query continuously
  72. while(True):
  73. question = input("Enter question: ")
  74. if question in ['q', 'exit', 'quit']:
  75. break
  76. answer = app.query(question)
  77. print(answer)
  78. ```
  79. </CodeGroup>
  80. <Snippet file="missing-vector-db-tip.mdx" />