Skip to content

Commit 02c450c

Browse files
authored
Merge pull request #27 from codefuse-ai/modelcache_dev_mm
Modelcache for mm
2 parents 2e22e05 + e6cfcb8 commit 02c450c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

65 files changed

+2851
-13
lines changed

.gitignore

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,5 +135,11 @@ dmypy.json
135135
/embedding_npy
136136
/flask_server
137137
*.bin
138+
**/maya_embedding_service
139+
140+
*.ini
141+
142+
**/multicache_serving.py
138143
**/modelcache_serving.py
139-
*.ini
144+
145+
**/model/

flask4modelcache.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,6 @@ def user_backend():
177177
return json.dumps(result)
178178

179179
if request_type == 'register':
180-
# iat_type = param_dict.get("iat_type")
181180
response = adapter.ChatCompletion.create_register(
182181
model=model
183182
)

model/clip_zh/__init__.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# -*- coding: utf-8 -*-
2+
"""
3+
Alipay.com Inc.
4+
Copyright (c) 2004-2023 All Rights Reserved.
5+
------------------------------------------------------
6+
File Name : __init__.py.py
7+
Author : fuhui.phe
8+
Create Time : 2024/5/7 14:05
9+
Description : description what the main function of this file
10+
Change Activity:
11+
version0 : 2024/5/7 14:05 by fuhui.phe init
12+
"""

modelcache/adapter/adapter_query.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,17 +30,20 @@ def adapt_query(cache_data_convert, *args, **kwargs):
3030
report_func=chat_cache.report.embedding,
3131
)(pre_embedding_data)
3232

33+
# print('embedding_data: {}'.format(embedding_data))
34+
3335
if cache_enable:
3436
cache_data_list = time_cal(
3537
chat_cache.data_manager.search,
36-
func_name="milvus_search",
38+
func_name="vector_search",
3739
report_func=chat_cache.report.search,
3840
)(
3941
embedding_data,
4042
extra_param=context.get("search_func", None),
4143
top_k=kwargs.pop("top_k", -1),
4244
model=model
4345
)
46+
print('cache_data_list: {}'.format(cache_data_list))
4447
cache_answers = []
4548
cache_questions = []
4649
cache_ids = []
@@ -78,8 +81,8 @@ def adapt_query(cache_data_convert, *args, **kwargs):
7881
return
7982

8083
for cache_data in cache_data_list:
84+
print('cache_data: {}'.format(cache_data))
8185
primary_id = cache_data[1]
82-
start_time = time.time()
8386
ret = chat_cache.data_manager.get_scalar_data(
8487
cache_data, extra_param=context.get("get_scalar_data", None)
8588
)

modelcache/core.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
from modelcache.processor.post import first
55
from modelcache.similarity_evaluation import ExactMatchEvaluation
66
from modelcache.similarity_evaluation import SimilarityEvaluation
7-
from modelcache.embedding.string import to_embeddings as string_embedding
7+
from modelcache.embedding.string_text import to_embeddings as string_embedding
88
from modelcache.report import Report
99
from modelcache.config import Config
1010
from modelcache.utils.cache_func import cache_all
@@ -19,7 +19,10 @@ def __init__(self):
1919
self.cache_enable_func = None
2020
self.query_pre_embedding_func = None
2121
self.insert_pre_embedding_func = None
22+
self.mm_query_pre_embedding_func = None
23+
self.mm_insert_pre_embedding_func = None
2224
self.embedding_func = None
25+
self.embedding_concurrent_func = None
2326
self.data_manager: Optional[DataManager] = None
2427
self.similarity_evaluation: Optional[SimilarityEvaluation] = None
2528
self.post_process_messages_func = None
File renamed without changes.
File renamed without changes.

modelcache/manager/data_manager.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,7 @@ def import_data(
212212
cache_datas.append([ans, question, embedding_data, model])
213213

214214
ids = self.s.batch_insert(cache_datas)
215+
print('ids: {}'.format(ids))
215216
logging.info('ids: {}'.format(ids))
216217
self.v.mul_add(
217218
[

modelcache/manager/scalar_data/base.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -94,10 +94,6 @@ class CacheStorage(metaclass=ABCMeta):
9494
def create(self):
9595
pass
9696

97-
@abstractmethod
98-
def batch_insert(self, all_data: List[CacheData]):
99-
pass
100-
10197
@abstractmethod
10298
def insert_query_resp(self, query_resp, **kwargs):
10399
pass

modelcache/manager/vector_data/milvus.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,7 @@ def _get_collection(self, collection_name):
136136

137137
def mul_add(self, datas: List[VectorData], model=None):
138138
collection_name_model = self.collection_name + '_' + model
139+
print('collection_name_model: {}'.format(collection_name_model))
139140
self._create_collection(collection_name_model)
140141

141142
data_array, id_array = map(list, zip(*((data.data, data.id) for data in datas)))
@@ -147,6 +148,7 @@ def search(self, data: np.ndarray, top_k: int = -1, model=None):
147148
if top_k == -1:
148149
top_k = self.top_k
149150
collection_name_model = self.collection_name + '_' + model
151+
print('collection_name_model: {}'.format(collection_name_model))
150152
self._create_collection(collection_name_model)
151153
search_result = self.col.search(
152154
data=data.reshape(1, -1).tolist(),

0 commit comments

Comments
 (0)