YanSte commited on
Commit
b61e892
·
1 Parent(s): d5e3b99

removed torch from requirement lightrag server

Browse files
Files changed (3) hide show
  1. README.md +3 -0
  2. lightrag/api/requirements.txt +0 -1
  3. lightrag/llm/hf.py +6 -43
README.md CHANGED
@@ -246,6 +246,9 @@ rag = LightRAG(
246
  <summary> Using Hugging Face Models </summary>
247
 
248
  * If you want to use Hugging Face models, you only need to set LightRAG as follows:
 
 
 
249
  ```python
250
  from lightrag.llm import hf_model_complete, hf_embed
251
  from transformers import AutoModel, AutoTokenizer
 
246
  <summary> Using Hugging Face Models </summary>
247
 
248
  * If you want to use Hugging Face models, you only need to set LightRAG as follows:
249
+
250
+ See lightrag_hf_demo.py
251
+
252
  ```python
253
  from lightrag.llm import hf_model_complete, hf_embed
254
  from transformers import AutoModel, AutoTokenizer
lightrag/api/requirements.txt CHANGED
@@ -6,5 +6,4 @@ python-dotenv
6
  python-multipart
7
  tenacity
8
  tiktoken
9
- torch
10
  uvicorn
 
6
  python-multipart
7
  tenacity
8
  tiktoken
 
9
  uvicorn
lightrag/llm/hf.py CHANGED
@@ -1,47 +1,7 @@
1
- """
2
- Hugging face LLM Interface Module
3
- ==========================
4
-
5
- This module provides interfaces for interacting with Hugging face's language models,
6
- including text generation and embedding capabilities.
7
-
8
- Author: Lightrag team
9
- Created: 2024-01-24
10
- License: MIT License
11
-
12
- Copyright (c) 2024 Lightrag
13
-
14
- Permission is hereby granted, free of charge, to any person obtaining a copy
15
- of this software and associated documentation files (the "Software"), to deal
16
- in the Software without restriction, including without limitation the rights
17
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
18
- copies of the Software, and to permit persons to whom the Software is
19
- furnished to do so, subject to the following conditions:
20
-
21
- Version: 1.0.0
22
-
23
- Change Log:
24
- - 1.0.0 (2024-01-24): Initial release
25
- * Added async chat completion support
26
- * Added embedding generation
27
- * Added stream response capability
28
-
29
- Dependencies:
30
- - transformers
31
- - numpy
32
- - pipmaster
33
- - Python >= 3.10
34
-
35
- Usage:
36
- from llm_interfaces.hf import hf_model_complete, hf_embed
37
- """
38
-
39
- __version__ = "1.0.0"
40
- __author__ = "lightrag Team"
41
- __status__ = "Production"
42
-
43
  import copy
44
  import os
 
 
45
  import pipmaster as pm # Pipmaster for dynamic library install
46
 
47
  # install specific modules
@@ -51,9 +11,12 @@ if not pm.is_installed("torch"):
51
  pm.install("torch")
52
  if not pm.is_installed("tenacity"):
53
  pm.install("tenacity")
 
 
 
 
54
 
55
  from transformers import AutoTokenizer, AutoModelForCausalLM
56
- from functools import lru_cache
57
  from tenacity import (
58
  retry,
59
  stop_after_attempt,
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  import copy
2
  import os
3
+ from functools import lru_cache
4
+
5
  import pipmaster as pm # Pipmaster for dynamic library install
6
 
7
  # install specific modules
 
11
  pm.install("torch")
12
  if not pm.is_installed("tenacity"):
13
  pm.install("tenacity")
14
+ if not pm.is_installed("numpy"):
15
+ pm.install("numpy")
16
+ if not pm.is_installed("tenacity"):
17
+ pm.install("tenacity")
18
 
19
  from transformers import AutoTokenizer, AutoModelForCausalLM
 
20
  from tenacity import (
21
  retry,
22
  stop_after_attempt,