xiaothink 1.2.2__tar.gz → 1.2.4__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (22) hide show
  1. {xiaothink-1.2.2/xiaothink.egg-info → xiaothink-1.2.4}/PKG-INFO +23 -2
  2. {xiaothink-1.2.2 → xiaothink-1.2.4}/README.md +22 -1
  3. {xiaothink-1.2.2 → xiaothink-1.2.4}/setup.py +1 -1
  4. {xiaothink-1.2.2 → xiaothink-1.2.4}/xiaothink/llm/inference/build_model.py +17 -1
  5. {xiaothink-1.2.2 → xiaothink-1.2.4}/xiaothink/llm/inference/test.py +16 -0
  6. {xiaothink-1.2.2 → xiaothink-1.2.4}/xiaothink/llm/inference/test_formal.py +18 -4
  7. {xiaothink-1.2.2 → xiaothink-1.2.4}/xiaothink/llm/inference/test_vision.py +14 -0
  8. {xiaothink-1.2.2 → xiaothink-1.2.4}/xiaothink/llm/inference/vision_api.py +2 -2
  9. {xiaothink-1.2.2 → xiaothink-1.2.4/xiaothink.egg-info}/PKG-INFO +23 -2
  10. {xiaothink-1.2.2 → xiaothink-1.2.4}/LICENSE +0 -0
  11. {xiaothink-1.2.2 → xiaothink-1.2.4}/MANIFEST.in +0 -0
  12. {xiaothink-1.2.2 → xiaothink-1.2.4}/NOTICE +0 -0
  13. {xiaothink-1.2.2 → xiaothink-1.2.4}/setup.cfg +0 -0
  14. {xiaothink-1.2.2 → xiaothink-1.2.4}/xiaothink/__init__.py +0 -0
  15. {xiaothink-1.2.2 → xiaothink-1.2.4}/xiaothink/llm/__init__.py +0 -0
  16. {xiaothink-1.2.2 → xiaothink-1.2.4}/xiaothink/llm/img_zip/__init__.py +0 -0
  17. {xiaothink-1.2.2 → xiaothink-1.2.4}/xiaothink/llm/img_zip/img_zip.py +0 -0
  18. {xiaothink-1.2.2 → xiaothink-1.2.4}/xiaothink/llm/inference/__init__.py +0 -0
  19. {xiaothink-1.2.2 → xiaothink-1.2.4}/xiaothink.egg-info/SOURCES.txt +0 -0
  20. {xiaothink-1.2.2 → xiaothink-1.2.4}/xiaothink.egg-info/dependency_links.txt +0 -0
  21. {xiaothink-1.2.2 → xiaothink-1.2.4}/xiaothink.egg-info/requires.txt +0 -0
  22. {xiaothink-1.2.2 → xiaothink-1.2.4}/xiaothink.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: xiaothink
3
- Version: 1.2.2
3
+ Version: 1.2.4
4
4
  Summary: 一个AI工具包,帮助用户快速调用小思框架(Xiaothink)相关接口。
5
5
  Home-page: UNKNOWN
6
6
  Author: Shi Jingqi
@@ -255,7 +255,7 @@ python -m xiaothink.llm.img_zip.img_zip
255
255
  ### 2. Python 代码调用
256
256
 
257
257
  ```python
258
- from xiaothink.llm.img_zip import ImgZip
258
+ from xiaothink.llm.img_zip.img_zip import ImgZip
259
259
 
260
260
  # 初始化实例
261
261
  img_zip = ImgZip(model_path='path/to/your/imgzip_model.keras')
@@ -400,9 +400,30 @@ if __name__ == '__main__':
400
400
  2. 推荐使用经过指令微调的模型(如`t6_standard`),非微调模型可能影响分类精度
401
401
  4. 输出结果格式为:{'积极': 0.6667, '消极': 0.1667, '中性': 0.1667}
402
402
 
403
+
404
+ ---
405
+ 小思框架系列模型名称、其对应MT(模型架构版本)以及form(模型prompt传入格式)一览:
406
+ | 模型名称(按发布时间) | mt 参数 | form 参数 |
407
+ |-----------------------|------------------|-------------|
408
+ | Xiaothink-T6-0.08B | mt='t6_beta_dense'| form=1 |
409
+ | Xiaothink-T6-0.15B | mt='t6_standard' | form=1 |
410
+ | Xiaothink-T6-0.02B | mt='t6_fast' | form=1 |
411
+ | Xiaothink-T6-0.5B | mt='t6_large' | form=1 |
412
+ | Xiaothink-T6-0.5B-pretrain| mt='t6_large' | form='pretrain' |
413
+
403
414
  ---
404
415
 
405
416
  ## 更新日志
417
+ ### 版本 1.2.4 (2025-08-30)
418
+ - **更新接口**:
419
+ - 更新文档中ImgZIP相关接口的导入方法为:from xiaothink.llm.img_zip.img_zip import ImgZip
420
+
421
+ ### 版本 1.2.3 (2025-08-30)
422
+ - **新增功能**:
423
+ - 添加了Xiaothink-T6-0.02B系列模型(MT='t6_fast')
424
+ - 添加了Xiaothink-T6-0.5B系列模型(MT='t6_large')
425
+ - 在model.chat方法中添加了form='pretrain'的支持,t6系列指令微调的模型应使用form=1,预训练模型应使用form='pretrain'
426
+
406
427
  ### 版本 1.2.2 (2025-08-18)
407
428
  - **新增功能**:
408
429
  - 新增情感分类工具,通过`ClassifyModel`实现文本情感倾向分析
@@ -230,7 +230,7 @@ python -m xiaothink.llm.img_zip.img_zip
230
230
  ### 2. Python 代码调用
231
231
 
232
232
  ```python
233
- from xiaothink.llm.img_zip import ImgZip
233
+ from xiaothink.llm.img_zip.img_zip import ImgZip
234
234
 
235
235
  # 初始化实例
236
236
  img_zip = ImgZip(model_path='path/to/your/imgzip_model.keras')
@@ -375,9 +375,30 @@ if __name__ == '__main__':
375
375
  2. 推荐使用经过指令微调的模型(如`t6_standard`),非微调模型可能影响分类精度
376
376
  4. 输出结果格式为:{'积极': 0.6667, '消极': 0.1667, '中性': 0.1667}
377
377
 
378
+
379
+ ---
380
+ 小思框架系列模型名称、其对应MT(模型架构版本)以及form(模型prompt传入格式)一览:
381
+ | 模型名称(按发布时间) | mt 参数 | form 参数 |
382
+ |-----------------------|------------------|-------------|
383
+ | Xiaothink-T6-0.08B | mt='t6_beta_dense'| form=1 |
384
+ | Xiaothink-T6-0.15B | mt='t6_standard' | form=1 |
385
+ | Xiaothink-T6-0.02B | mt='t6_fast' | form=1 |
386
+ | Xiaothink-T6-0.5B | mt='t6_large' | form=1 |
387
+ | Xiaothink-T6-0.5B-pretrain| mt='t6_large' | form='pretrain' |
388
+
378
389
  ---
379
390
 
380
391
  ## 更新日志
392
+ ### 版本 1.2.4 (2025-08-30)
393
+ - **更新接口**:
394
+ - 更新文档中ImgZIP相关接口的导入方法为:from xiaothink.llm.img_zip.img_zip import ImgZip
395
+
396
+ ### 版本 1.2.3 (2025-08-30)
397
+ - **新增功能**:
398
+ - 添加了Xiaothink-T6-0.02B系列模型(MT='t6_fast')
399
+ - 添加了Xiaothink-T6-0.5B系列模型(MT='t6_large')
400
+ - 在model.chat方法中添加了form='pretrain'的支持,t6系列指令微调的模型应使用form=1,预训练模型应使用form='pretrain'
401
+
381
402
  ### 版本 1.2.2 (2025-08-18)
382
403
  - **新增功能**:
383
404
  - 新增情感分类工具,通过`ClassifyModel`实现文本情感倾向分析
@@ -10,7 +10,7 @@ with open("NOTICE", "r", encoding='utf-8') as notice_file:
10
10
 
11
11
  setuptools.setup(
12
12
  name="xiaothink", # 模块名称
13
- version="1.2.2", # 当前版本
13
+ version="1.2.4", # 当前版本
14
14
  author="Shi Jingqi", # 使用真实姓名而非昵称
15
15
  author_email="xiaothink@foxmail.com", # 作者邮箱
16
16
  description="一个AI工具包,帮助用户快速调用小思框架(Xiaothink)相关接口。", # 模块简介
@@ -223,6 +223,22 @@ dic={1:[int(256*4*2*0.7),int(1024*4*2*0.7),512],
223
223
  'all_maxlen':2048,
224
224
  },
225
225
  512],
226
+
227
+ 't6_fast':[int(256),{'rnn_units':int(600), 'n_layer':1,'embed_q':0.4,'router_units':64,
228
+ 'trans_layers':17,'dff_factor':2,'num_heads':4,
229
+ 'trans_window':140,#130,
230
+ 'all_maxlen':2048,
231
+ },
232
+ 512],
233
+
234
+ 't6_large':[int(920),{'rnn_units':int(1200), 'n_layer':1,'embed_q':0.4,'router_units':512,
235
+ 'trans_layers':41,'dff_factor':2,'num_heads':4,
236
+ 'trans_window':130,#130,
237
+ 'all_maxlen':2048,
238
+ },
239
+ 512],
240
+
241
+
226
242
 
227
243
 
228
244
  }
@@ -2676,7 +2692,7 @@ if 1:
2676
2692
 
2677
2693
  return model
2678
2694
 
2679
- elif mt=='t6_standard':
2695
+ elif mt=='t6_standard' or mt=='t6_fast' or mt=='t6_large':
2680
2696
  # 参数设置
2681
2697
  maxlen = window
2682
2698
  #vocab_size = 20000
@@ -233,6 +233,22 @@ dic={1:[int(256*4*2*0.7),int(1024*4*2*0.7),512],
233
233
  'all_maxlen':2048,
234
234
  },
235
235
  512],
236
+
237
+ 't6_fast':[int(256),{'rnn_units':int(600), 'n_layer':1,'embed_q':0.4,'router_units':64,
238
+ 'trans_layers':17,'dff_factor':2,'num_heads':4,
239
+ 'trans_window':140,#130,
240
+ 'all_maxlen':2048,
241
+ },
242
+ 512],
243
+
244
+ 't6_large':[int(920),{'rnn_units':int(1200), 'n_layer':1,'embed_q':0.4,'router_units':512,
245
+ 'trans_layers':41,'dff_factor':2,'num_heads':4,
246
+ 'trans_window':130,#130,
247
+ 'all_maxlen':2048,
248
+ },
249
+ 512],
250
+
251
+
236
252
 
237
253
  }
238
254
 
@@ -353,6 +353,19 @@ class QianyanModel:
353
353
  '"}]}',
354
354
  '"}',
355
355
  ]
356
+ elif form=='pretrain':
357
+ if self.his!='':
358
+ self.his+='\n{inp} '.replace('{inp}',text)
359
+
360
+ else:
361
+ self.his='{inp} '.replace('{inp}',text)
362
+
363
+ #print(self.his)
364
+ inp='{"text": "<s>{his}'.replace('{his}',self.his)
365
+ stopc=[
366
+ '</s>',
367
+ '"}',
368
+ ]
356
369
  else:
357
370
  print('Err')
358
371
  return '-1: form error'
@@ -360,7 +373,7 @@ class QianyanModel:
360
373
  if ontime:
361
374
  funct=lambda a:print(a,end='',flush=True)
362
375
  print('\n【实时输出】')
363
- #print(funct)
376
+ #print(inp)
364
377
  if loop:
365
378
  inf=test.generate_texts_untilstr_loop
366
379
  else:
@@ -377,7 +390,8 @@ class QianyanModel:
377
390
  self.his+=ret
378
391
  elif form==1:
379
392
  self.his+=', {"role": "assistant", "content": "{inp}"}'.replace('{inp}',ret)
380
-
393
+ elif form=='pretrain':
394
+ self.his+='{inp}'.replace('{inp}',ret)
381
395
  return replace_vec(ret,self.v_path,self.use_patch,imgzip_model_path=self.imgzip_model_path)#ret
382
396
 
383
397
  def chat_(self,text,temp=0.68,max_len=2048,form=1,ontime=True,
@@ -457,10 +471,10 @@ class QianyanModel:
457
471
  )
458
472
  return ret
459
473
 
460
- def img2ms(self, img_path, temp=0.28, pre_text='', pass_start_char=[]):
474
+ def img2ms(self, img_path, temp=0.28, pre_text='', pass_start_char=[], ontime=False, max_len=128):
461
475
  self.clean_his()
462
476
  self.model.reset_states()
463
- ret=self.chat('<img>'+img_path+'</img>请你描述图片内容', temp=temp, pre_text=pre_text, pass_start_char=pass_start_char, ontime=False)
477
+ ret=self.chat('<img>'+img_path+'</img>请你描述图片内容', repetition_penalty=1.0, temp=temp, pre_text=pre_text, pass_start_char=pass_start_char, ontime=ontime, max_len=max_len)
464
478
  self.clean_his()
465
479
  self.model.reset_states()
466
480
  return ret
@@ -233,6 +233,20 @@ dic={1:[int(256*4*2*0.7),int(1024*4*2*0.7),512],
233
233
  'all_maxlen':2048,
234
234
  },
235
235
  512],
236
+ 't6_fast':[int(256),{'rnn_units':int(600), 'n_layer':1,'embed_q':0.4,'router_units':64,
237
+ 'trans_layers':17,'dff_factor':2,'num_heads':4,
238
+ 'trans_window':140,#130,
239
+ 'all_maxlen':2048,
240
+ },
241
+ 512],
242
+
243
+ 't6_large':[int(920),{'rnn_units':int(1200), 'n_layer':1,'embed_q':0.4,'router_units':512,
244
+ 'trans_layers':41,'dff_factor':2,'num_heads':4,
245
+ 'trans_window':130,#130,
246
+ 'all_maxlen':2048,
247
+ },
248
+ 512],
249
+
236
250
 
237
251
  }
238
252
 
@@ -207,7 +207,7 @@ def split_autoencoder(model):
207
207
  decoder = model.get_layer('decoder')
208
208
  return model, encoder, decoder
209
209
 
210
- def image_to_compressed(encoder, img_path, vocab, patch=True):
210
+ def image_to_compressed(encoder, img_path, vocab, n_min, n_max, patch=True):
211
211
  """将图像编码为压缩字符串,支持分块处理"""
212
212
  if patch:
213
213
  # 分块处理模式
@@ -242,7 +242,7 @@ def image_to_compressed(encoder, img_path, vocab, patch=True):
242
242
  vector = encoder.predict(np.expand_dims(img_array, axis=0), verbose=0)[0]
243
243
  return compress_vector(vector, vocab)
244
244
 
245
- def compressed_to_image(decoder, compressed_str, vocab, patch=True):
245
+ def compressed_to_image(decoder, compressed_str, vocab, n_min, n_max, patch=True):
246
246
  """从压缩字符串解码为图像,支持分块处理"""
247
247
  # 先解压整个字符串
248
248
  raw_str = compressed_str
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: xiaothink
3
- Version: 1.2.2
3
+ Version: 1.2.4
4
4
  Summary: 一个AI工具包,帮助用户快速调用小思框架(Xiaothink)相关接口。
5
5
  Home-page: UNKNOWN
6
6
  Author: Shi Jingqi
@@ -255,7 +255,7 @@ python -m xiaothink.llm.img_zip.img_zip
255
255
  ### 2. Python 代码调用
256
256
 
257
257
  ```python
258
- from xiaothink.llm.img_zip import ImgZip
258
+ from xiaothink.llm.img_zip.img_zip import ImgZip
259
259
 
260
260
  # 初始化实例
261
261
  img_zip = ImgZip(model_path='path/to/your/imgzip_model.keras')
@@ -400,9 +400,30 @@ if __name__ == '__main__':
400
400
  2. 推荐使用经过指令微调的模型(如`t6_standard`),非微调模型可能影响分类精度
401
401
  4. 输出结果格式为:{'积极': 0.6667, '消极': 0.1667, '中性': 0.1667}
402
402
 
403
+
404
+ ---
405
+ 小思框架系列模型名称、其对应MT(模型架构版本)以及form(模型prompt传入格式)一览:
406
+ | 模型名称(按发布时间) | mt 参数 | form 参数 |
407
+ |-----------------------|------------------|-------------|
408
+ | Xiaothink-T6-0.08B | mt='t6_beta_dense'| form=1 |
409
+ | Xiaothink-T6-0.15B | mt='t6_standard' | form=1 |
410
+ | Xiaothink-T6-0.02B | mt='t6_fast' | form=1 |
411
+ | Xiaothink-T6-0.5B | mt='t6_large' | form=1 |
412
+ | Xiaothink-T6-0.5B-pretrain| mt='t6_large' | form='pretrain' |
413
+
403
414
  ---
404
415
 
405
416
  ## 更新日志
417
+ ### 版本 1.2.4 (2025-08-30)
418
+ - **更新接口**:
419
+ - 更新文档中ImgZIP相关接口的导入方法为:from xiaothink.llm.img_zip.img_zip import ImgZip
420
+
421
+ ### 版本 1.2.3 (2025-08-30)
422
+ - **新增功能**:
423
+ - 添加了Xiaothink-T6-0.02B系列模型(MT='t6_fast')
424
+ - 添加了Xiaothink-T6-0.5B系列模型(MT='t6_large')
425
+ - 在model.chat方法中添加了form='pretrain'的支持,t6系列指令微调的模型应使用form=1,预训练模型应使用form='pretrain'
426
+
406
427
  ### 版本 1.2.2 (2025-08-18)
407
428
  - **新增功能**:
408
429
  - 新增情感分类工具,通过`ClassifyModel`实现文本情感倾向分析
File without changes
File without changes
File without changes
File without changes