Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
chenpangpang
open-webui
Commits
5c6e30cb
Unverified
Commit
5c6e30cb
authored
Jun 30, 2024
by
Timothy Jaeryang Baek
Committed by
GitHub
Jun 30, 2024
Browse files
Merge pull request #3558 from cheahjs/refac/reduce-startup-mem-usage
refac: reduce startup memory usage
parents
a55d6e60
a48ac6a2
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
8 additions
and
6 deletions
+8
-6
backend/apps/audio/main.py
backend/apps/audio/main.py
+2
-1
backend/apps/images/main.py
backend/apps/images/main.py
+0
-1
backend/apps/rag/main.py
backend/apps/rag/main.py
+4
-2
backend/apps/rag/utils.py
backend/apps/rag/utils.py
+2
-2
No files found.
backend/apps/audio/main.py
View file @
5c6e30cb
...
...
@@ -14,7 +14,6 @@ from fastapi import (
from
fastapi.responses
import
StreamingResponse
,
JSONResponse
,
FileResponse
from
fastapi.middleware.cors
import
CORSMiddleware
from
faster_whisper
import
WhisperModel
from
pydantic
import
BaseModel
import
uuid
...
...
@@ -277,6 +276,8 @@ def transcribe(
f
.
close
()
if
app
.
state
.
config
.
STT_ENGINE
==
""
:
from
faster_whisper
import
WhisperModel
whisper_kwargs
=
{
"model_size_or_path"
:
WHISPER_MODEL
,
"device"
:
whisper_device_type
,
...
...
backend/apps/images/main.py
View file @
5c6e30cb
...
...
@@ -12,7 +12,6 @@ from fastapi import (
Form
,
)
from
fastapi.middleware.cors
import
CORSMiddleware
from
faster_whisper
import
WhisperModel
from
constants
import
ERROR_MESSAGES
from
utils.utils
import
(
...
...
backend/apps/rag/main.py
View file @
5c6e30cb
...
...
@@ -48,8 +48,6 @@ import mimetypes
import
uuid
import
json
import
sentence_transformers
from
apps.webui.models.documents
import
(
Documents
,
DocumentForm
,
...
...
@@ -190,6 +188,8 @@ def update_embedding_model(
update_model
:
bool
=
False
,
):
if
embedding_model
and
app
.
state
.
config
.
RAG_EMBEDDING_ENGINE
==
""
:
import
sentence_transformers
app
.
state
.
sentence_transformer_ef
=
sentence_transformers
.
SentenceTransformer
(
get_model_path
(
embedding_model
,
update_model
),
device
=
DEVICE_TYPE
,
...
...
@@ -204,6 +204,8 @@ def update_reranking_model(
update_model
:
bool
=
False
,
):
if
reranking_model
:
import
sentence_transformers
app
.
state
.
sentence_transformer_rf
=
sentence_transformers
.
CrossEncoder
(
get_model_path
(
reranking_model
,
update_model
),
device
=
DEVICE_TYPE
,
...
...
backend/apps/rag/utils.py
View file @
5c6e30cb
...
...
@@ -442,8 +442,6 @@ from langchain_core.documents import BaseDocumentCompressor, Document
from
langchain_core.callbacks
import
Callbacks
from
langchain_core.pydantic_v1
import
Extra
from
sentence_transformers
import
util
class
RerankCompressor
(
BaseDocumentCompressor
):
embedding_function
:
Any
...
...
@@ -468,6 +466,8 @@ class RerankCompressor(BaseDocumentCompressor):
[(
query
,
doc
.
page_content
)
for
doc
in
documents
]
)
else
:
from
sentence_transformers
import
util
query_embedding
=
self
.
embedding_function
(
query
)
document_embedding
=
self
.
embedding_function
(
[
doc
.
page_content
for
doc
in
documents
]
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment