Metadata-Version: 2.1
Name: xiaothink
Version: 1.2.5.2
Summary: =?unknown-8bit?b?5LiA5LiqQUnlt6XlhbfljIXvvIzluK7liqnnlKjmiLflv6vpgJ/osIPnlKjlsI/mgJ3moYbmnrbvvIhYaWFvdGhpbmvvvInnm7jlhbPmjqXlj6PjgII=?=
Author: Shi Jingqi
Author-email: xiaothink@foxmail.com
License: Apache License 2.0
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: Intended Audience :: Science/Research
Classifier: License :: OSI Approved :: Apache Software License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
Classifier: Operating System :: OS Independent
Requires-Python: >=3
Description-Content-Type: text/markdown
License-File: LICENSE
License-File: NOTICE
Requires-Dist: numpy (>=1.21.0)
Requires-Dist: tensorflow (>=2.10.0)

# Xiaothink Python ������������������

[![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)
Xiaothink ���������������������������������NLP���������������AI������������������������������������������������������������������������������������Xiaothink Python ������������������������������������������������������������������������������������������������������������������������������������������������������������������������������

## ������
1. [������](#������)
2. [������������������](#������������������)
3. [������������������������������������](#������������������������������������)
4. [��������������������������� (img_zip)](#���������������������������-img_zip)
5. [������������������](#������������������)
6. [������������](#������������)

---

## ������

������������������������ pip ������ Xiaothink ���������

```bash
pip install xiaothink
```

---

## ���������������������������������2025���7���17������������������������������������WebAI���������������������AI���������������������������������������������������������������

---

## License

This project is licensed under the Apache License, Version 2.0 - see the [LICENSE](LICENSE) file for details.

The [NOTICE](NOTICE) file contains additional attribution information for the proprietary technologies included in this module.

---

## ���������������������������

������������������������������������������������������������������������������������������������������������

### ������������������������������������������������

������������������������������

### ������������

```python
import xiaothink.llm.inference.test_formal as tf

model = tf.QianyanModel(
    ckpt_dir=r'path/to/your/t6_model',
    MT='t6_beta_dense',
    vocab=r'path/to/your/vocab'# vocab������������������������������������
)

while True:
    inp = input('������������')
    if inp == '[CLEAN]':
        print('���������������������\n\n')
        model.clean_his()
        continue
    re = model.chat_SingleTurn(inp, temp=0.32)  # ������ chat_SingleTurn ������������������
    print('\n������������', re, '\n')
```

### ������������

������������������������������

### ������������

```python
import xiaothink.llm.inference.test_formal as tf

model = tf.QianyanModel(
    ckpt_dir=r'path/to/your/t6_model',
    MT='t6_beta_dense',
    vocab=r'path/to/your/vocab'# vocab������������������������������������
)

while True:
    inp = input('������������')
    if inp == '[CLEAN]':
        print('���������������������\n\n')
        model.clean_his()
        continue
    re = model.chat(inp, temp=0.32)  # ������ chat ������������������
    print('\n������������', re, '\n')
```

### ������������

���������������������������������������

### ������������

```python
import xiaothink.llm.inference.test as test

MT = 't6_beta_dense'
m, d = test.load(
    ckpt_dir=r'path/to/your/t6_model',
    MT='t6_beta_dense',
    vocab=r'path/to/your/vocab'# vocab������������������������������������
)

inp='���������'
belle_chat = '{"conversations": [{"role": "user", "content": {inp}}, {"role": "assistant", "content": "'.replace('{inp}', inp)    # t6���������������������������������������������instruct������
inp_m = belle_chat

ret = test.generate_texts_loop(m, d, inp_m,    
                               num_generate=100,
                               every=lambda a: print(a, end='', flush=True),
                               temperature=0.32,
                               pass_char=['���'])    #������t6���������������<unk>������
```

**������������**������������������������������������ `model.chat` ������������������������������������������������������������������������������ `test.generate_texts_loop` ���������** ��������������� `model.chat_SingleTurn` ������������������������������������ **

---

## ������������������������������������

### ���������������

���1.2.0������������������������������������������������������
1. **���������������������(img_zip)**������������������������token������������������������������
2. **���������������������**���������������������������������������������������������������������������������������

������������������������
- ������������������������������������������������������������
- ������img_zip������������������������������������������
- ������������������������������

### ������������������������

���������������������������������������������������������������������������������������

```python
from xiaothink.llm.inference.test_formal import QianyanModel

if __name__ == '__main__':
    model = QianyanModel(
        ckpt_dir=r'path/to/your/vision_model',
        MT='t6_standard_vision',  # ���������������������������������
        vocab=r'path/to/your/vocab.txt',
        imgzip_model_path='path/to/img_zip/model.keras'  # ������img_zip������������
    )

    temp = 0.28  # ������������
    
    while True:
        inp = input('������������')
        if inp == '[CLEAN]':
            print('���������������������\n\n')
            model.clean_his()
            continue
        # ������chat_vision������������
        ret = model.chat_vision(inp, temp=temp, pre_text='', pass_start_char=[])
        print('\n������������', ret, '\n')
```

**������������**���
- ������������������������ `chat_vision` ��������������������� `chat`���������������������������������
- ���������������������������������������������img_zip���������������������������
- ���������������������������������������������������������token������

### ������������������

���������������������������������

1. **img2ms**���������������������������������������
   ```python
   description = model.img2ms('path/to/image.jpg', temp=0.28)
   print(description)
   ```

2. **img2ms_vision**������������������������������������
   ```python
   description = model.img2ms_vision('path/to/image.jpg', temp=0.28, max_shape=224)
   print(description)
   ```

### ������������������

������������������������������������������������
```python
<img>���������������URL</img>������������������������
```

������������������������������������������������������������������������������������������

**������������**���
1. ������������������������������������������������������
2. ������������������������������������������������������
3. img_zip���������������������������������������������

---

## ��������������������������� (img_zip)

`img_zip` ���������������������������������������������/������������������������������������������������������������������������������������������

### 1. ���������������������

```bash
python -m xiaothink.llm.img_zip.img_zip
```

���������������������������������������������

```
===== img_zip ������������������������ =====
���������.keras������������: path/to/your/imgzip_model.keras
������������������!

���������������:
1. ������������
2. ������������
3. ������������
4. ������������
0. ������

��������� (0-6): 
```

### 2. Python ������������

```python
from xiaothink.llm.img_zip.img_zip import ImgZip

# ���������������
img_zip = ImgZip(model_path='path/to/your/imgzip_model.keras')

# ������������
compressed_path = img_zip.compress_image(
    img_path='input.jpg',
    patch=True,  # ������������������������
    save_path='compressed_img'  # ������������������
    ability=0.02,# 1.2.5���������������������������������������0.02������ability���0������������������������������������������������������������������������������������������������������������������������������
)

# ������������������: compressed_img.npy ��� compressed_img.shape

# ������������
img_zip.decompress_image(
    compressed_input='compressed_img',  # ������������������
    patch=True,  # ������������������������
    save_path='decompressed.jpg'  # ������������
)

# ������������
compressed_paths, metadata_path = img_zip.compress_video(
    video_path='input.mp4',
    output_dir='compressed_video',  # ������������
    patch=True  # ������������������������
)

# ������������
img_zip.decompress_video(
    compressed_dir='compressed_video',  # ������������������
    output_path='decompressed.mp4'  # ������������
)

# ������������������������
img_array = img_zip.image_to_array('input.jpg')
img_zip.save_image_array(img_array, 'image_array.npy')

# ���������������������
loaded_array = img_zip.load_image_array('image_array.npy')
img = img_zip.array_to_image(loaded_array)
img.save('restored.jpg')
```

### 3. ������������������

1. **������������** (`compress_image`)
   - `patch=True`: ������������������80x80���������������
   - ������������������: `.npy` (������������) ��� `.shape` (������������������)

2. **������������** (`decompress_image`)
   - ������`.npy`���`.shape`������������
   - ������������������������

3. **������������** (`compress_video`/`decompress_video`)
   - ������������������������������������
   - ���������������������������������������������
   - ������������������������������������



#### 4. ������������

| ������ | ������ | ������ |
|------|------|------|
| `model_path` | str | img_zip������������ (.keras������) |
| `patch` | bool | ������������������������ (���������True) |
| `save_path` | str | ������������������������ |
| `img_path` | str | ������������������ |
| `video_path` | str | ������������������ |
| `output_dir` | str | ������������������ |
| `output_path` | str | ������������������ |

#### 5. ������������������

1. **������������**:
   - ���������������������80x80���
   - ���������������������������������
   - ������������������������

2. **������������**:
   - ������������������������������
   - ������������������������ (fps, ���������)
   - ������������������������������������

3. **������������**:
   - ���������������������������������
   - ���������������������������������������

4. **������������**:
   - ���������������������������
   - ���������������������������

#### 6. ������������

1. ������������80x80������������������������������������ (`patch=True`)
2. ���������������������������������������������������������
3. ���������������������������������������
4. ������������������������������������������

������������Xiaothink������������������������������������������������������������������������������������������������������������������������������������������������AI���������������������������������������

---

## ������������������

���������������������������������������������������������������������������������������������������������������������������������������������������������������������������

### ������������
- ���������������������������������Xiaothink T6������������������������������������
- ���������������������������������������������������������������������������������
- ���������������������������������������������������
- ������������������������������������������������Xiaothink-T6-0.15B-ST

### ������������

```python
from xiaothink.llm.inference.test_formal import *
from xiaothink.llm.tools.classify import *

if __name__ == '__main__':
    # ���������������������������
    model = QianyanModel(
        ckpt_dir=r'path/to/your/t6_model',  # ������������������  ������������_ST���������
        MT='t6_standard',  # ������������������������������������
        vocab=r'path/to/your/vocab.txt',  # ���������������
        use_patch=0  # ������������������������������������������
    )
    
    # ���������������������������������������������������������
    cmodel = ClassifyModel(model)
    
    # ������������������������������������
    while True:
        inp = input('���������������')
        res = cmodel.emotion(inp)  # ������������������������
        print(res)  # ������������������������
```

### ������������
1. ���������������������������������������`QianyanModel`������������������������������������
2. ���������������������������������������������`t6_standard`���������������������������������������������
4. ������������������������{'������': 0.6667, '������': 0.1667, '������': 0.1667}


---
������������������������������������������MT������������������������������form���������prompt������������������������
| ���������������������������������              | mt ������           | form ������   |
|-----------------------|------------------|-------------|
| Xiaothink-T6-0.08B       | mt='t6_beta_dense'| form=1      |
| Xiaothink-T6-0.15B       | mt='t6_standard' | form=1      |
| Xiaothink-T6-0.02B       | mt='t6_fast'     | form=1      |
| Xiaothink-T6-0.5B        | mt='t6_large'    | form=1      |
| Xiaothink-T6-0.5B-pretrain| mt='t6_large'    | form='pretrain' |

---

## ������������
### ������ 1.2.5 (2025-09-02)
- **������������**���
  - ImgZIP���������������������������������������������������������������������������������������������������������������������������������������������������������������

### ������ 1.2.4 (2025-08-30)
- **������������**���
  - ���������������ImgZIP���������������������������������from xiaothink.llm.img_zip.img_zip import ImgZip

### ������ 1.2.3 (2025-08-30)
- **������������**���
  - ���������Xiaothink-T6-0.02B���������������MT='t6_fast'���
  - ���������Xiaothink-T6-0.5B���������������MT='t6_large'���
  - ���model.chat������������������form='pretrain'������������t6������������������������������������form=1���������������������������form='pretrain'

### ������ 1.2.2 (2025-08-18)
- **������������**���
  - ���������������������������������`ClassifyModel`������������������������������
  - ������`xiaothink.llm.tools.classify`������������������������������������������������������
  - ������`cmodel.emotion(inp)`���������������������������������������

### ������ 1.2.1 (2025-08-16)
- **������������**���
  - ���������Xiaothink-T6-0.15B���������������MT='t6_standard'���


### ������ 1.2.0 (2025-08-08)
- **���������������**���
  - ���������������������������������������������������������������������
  - ���������������������token(img_zip) + ���������������������������������
  - ������������������������������������������������������������������

- **������������**���
  - `model.chat_vision`���������������������������������
  - `model.img2ms`������������������������������������������
  - `model.img2ms_vision`������������������������������������������������max_shape���������
  
- **������������**���
  - ������ `xiaothink.llm.img_zip.img_zip` ���������������
  - ���������������������������������������
  - ���������������������������������������

- **������������**���
  - ������������������������ `chat_vision` ������
  - ���������������������img_zip���������������
  - ���������������������������������

### ������ 1.1.0 (2025-08-02)
- **������������**���
  - ������`img2ms`���`ms2img`������������������������������������������������
  - ������������������������AI���������������tokens
  - ������������������������������������������������+���������
  - test_formal������������������������������AI���������������tokens������������������������������������������������
  
- **������������**���
  - ���������������������������img_zip������
  - ������80x80x3������������������������
  - ������������96������������������������.7z���������������10%���������������
  
- **������������**���
  - ������������������`<img>{image_path}</img>`������������������
  - ���������������������������img_zip������������
  - ���������������������������������������������������������������


---

������������ Xiaothink Python ���������������������������������������

������������������������������������������������������xiaothink@foxmail.com���
