Upload 8 files
Browse files- README.md +78 -0
- added_tokens.json +5 -0
- config.json +28 -0
- generation_config.json +17 -0
- merges.txt +0 -0
- special_tokens_map.json +20 -0
- tokenizer_config.json +43 -0
- vocab.json +0 -0
README.md
ADDED
@@ -0,0 +1,78 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
pipeline_tag: text-generation
|
3 |
+
language:
|
4 |
+
- multilingual
|
5 |
+
inference: false
|
6 |
+
license: cc-by-nc-4.0
|
7 |
+
library_name: transformers
|
8 |
+
---
|
9 |
+
|
10 |
+
<br><br>
|
11 |
+
|
12 |
+
<p align="center">
|
13 |
+
<img src="https://aeiljuispo.cloudimg.io/v7/https://cdn-uploads.huggingface.co/production/uploads/603763514de52ff951d89793/AFoybzd5lpBQXEBrQHuTt.png?w=200&h=200&f=face" alt="Finetuner logo: Finetuner helps you to create experiments in order to improve embeddings on search tasks. It accompanies you to deliver the last mile of performance-tuning for neural search applications." width="150px">
|
14 |
+
</p>
|
15 |
+
|
16 |
+
<p align="center">
|
17 |
+
<b>Trained by <a href="https://jina.ai/"><b>Jina AI</b></a>.</b>
|
18 |
+
</p>
|
19 |
+
|
20 |
+
[Blog](https://jina.ai/news/reader-lm-small-language-models-for-cleaning-and-converting-html-to-markdown) | [Colab](https://colab.research.google.com/drive/1wXWyj5hOxEHY6WeHbOwEzYAC0WB1I5uA)
|
21 |
+
|
22 |
+
# Intro
|
23 |
+
|
24 |
+
Jina Reader-LM is a series of models that convert HTML content to Markdown content, which is useful for content conversion tasks. The model is trained on a curated collection of HTML content and its corresponding Markdown content.
|
25 |
+
|
26 |
+
# Models
|
27 |
+
|
28 |
+
| Name | Context Length | Download |
|
29 |
+
|-----------------|-------------------|-----------------------------------------------------------------------|
|
30 |
+
| reader-lm-0.5b | 256K | [🤗 Hugging Face](https://huggingface.co/jinaai/reader-lm-0.5b) |
|
31 |
+
| reader-lm-1.5b | 256K | [🤗 Hugging Face](https://huggingface.co/jinaai/reader-lm-1.5b) |
|
32 |
+
| |
|
33 |
+
|
34 |
+
# Get Started
|
35 |
+
|
36 |
+
## On Google Colab
|
37 |
+
The easiest way to experience reader-lm is by running [our Colab notebook](https://colab.research.google.com/drive/1wXWyj5hOxEHY6WeHbOwEzYAC0WB1I5uA),
|
38 |
+
where we demonstrate how to use reader-lm-1.5b to convert the HackerNews website into markdown. The notebook is optimized to run smoothly on Google Colab’s free T4 GPU tier. You can also load reader-lm-0.5b or change the URL to any website and explore the output. Note that the input (i.e., the prompt) to the model is the raw HTML—no prefix instruction is required.
|
39 |
+
|
40 |
+
## Local
|
41 |
+
|
42 |
+
To use this model, you need to install `transformers`:
|
43 |
+
|
44 |
+
```bash
|
45 |
+
pip install transformers<=4.43.4
|
46 |
+
```
|
47 |
+
|
48 |
+
Then, you can use the model as follows:
|
49 |
+
|
50 |
+
```python
|
51 |
+
# pip install transformers
|
52 |
+
from transformers import AutoModelForCausalLM, AutoTokenizer
|
53 |
+
checkpoint = "jinaai/reader-lm-1.5b"
|
54 |
+
|
55 |
+
device = "cuda" # for GPU usage or "cpu" for CPU usage
|
56 |
+
tokenizer = AutoTokenizer.from_pretrained(checkpoint)
|
57 |
+
model = AutoModelForCausalLM.from_pretrained(checkpoint).to(device)
|
58 |
+
|
59 |
+
# example html content
|
60 |
+
html_content = "<html><body><h1>Hello, world!</h1></body></html>"
|
61 |
+
|
62 |
+
messages = [{"role": "user", "content": html_content}]
|
63 |
+
input_text=tokenizer.apply_chat_template(messages, tokenize=False)
|
64 |
+
|
65 |
+
print(input_text)
|
66 |
+
|
67 |
+
inputs = tokenizer.encode(input_text, return_tensors="pt").to(device)
|
68 |
+
outputs = model.generate(inputs, max_new_tokens=1024, temperature=0, do_sample=False, repetition_penalty=1.08)
|
69 |
+
|
70 |
+
print(tokenizer.decode(outputs[0]))
|
71 |
+
```
|
72 |
+
|
73 |
+
## AWS Sagemaker & Azure Marketplace
|
74 |
+
[AWS 0.5b](https://aws.amazon.com/marketplace/pp/prodview-nli7b6dueo424?sr=0-1&ref_=beagle&applicationId=AWSMPContessa)
|
75 |
+
[AWS 1.5b](https://aws.amazon.com/marketplace/pp/prodview-ms27ixcwq3wjk?sr=0-2&ref_=beagle&applicationId=AWSMPContessa)
|
76 |
+
[Azure 0.5b](https://azuremarketplace.microsoft.com/en-us/marketplace/apps/jinaai.reader-lm-500m)
|
77 |
+
[Azure 1.5b](https://azuremarketplace.microsoft.com/en-us/marketplace/apps/jinaai.reader-lm-1500m)
|
78 |
+
|
added_tokens.json
ADDED
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"<|endoftext|>": 151643,
|
3 |
+
"<|im_end|>": 151645,
|
4 |
+
"<|im_start|>": 151644
|
5 |
+
}
|
config.json
ADDED
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"_name_or_path": "jinaai/qwen2-1.5b-reader",
|
3 |
+
"architectures": [
|
4 |
+
"Qwen2ForCausalLM"
|
5 |
+
],
|
6 |
+
"attention_dropout": 0.0,
|
7 |
+
"bos_token_id": 151643,
|
8 |
+
"eos_token_id": 151645,
|
9 |
+
"hidden_act": "silu",
|
10 |
+
"hidden_size": 1536,
|
11 |
+
"initializer_range": 0.02,
|
12 |
+
"intermediate_size": 8960,
|
13 |
+
"max_position_embeddings": 256000,
|
14 |
+
"max_window_layers": 28,
|
15 |
+
"model_type": "qwen2",
|
16 |
+
"num_attention_heads": 12,
|
17 |
+
"num_hidden_layers": 28,
|
18 |
+
"num_key_value_heads": 2,
|
19 |
+
"rms_norm_eps": 1e-06,
|
20 |
+
"rope_theta": 2000000,
|
21 |
+
"sliding_window": null,
|
22 |
+
"tie_word_embeddings": true,
|
23 |
+
"torch_dtype": "bfloat16",
|
24 |
+
"transformers_version": "4.43.3",
|
25 |
+
"use_cache": true,
|
26 |
+
"use_sliding_window": false,
|
27 |
+
"vocab_size": 151936
|
28 |
+
}
|
generation_config.json
ADDED
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"attn_implementation": "flash_attention_2",
|
3 |
+
"bos_token_id": 151643,
|
4 |
+
"do_sample": true,
|
5 |
+
"eos_token_id": [
|
6 |
+
151645,
|
7 |
+
151643
|
8 |
+
],
|
9 |
+
"pad_token_id": 151643,
|
10 |
+
"repetition_penalty": 1.1,
|
11 |
+
"rope_theta": 2000000,
|
12 |
+
"temperature": 0.7,
|
13 |
+
"top_k": 20,
|
14 |
+
"top_p": 0.8,
|
15 |
+
"transformers_version": "4.43.3",
|
16 |
+
"use_cache": false
|
17 |
+
}
|
merges.txt
ADDED
The diff for this file is too large to render.
See raw diff
|
|
special_tokens_map.json
ADDED
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"additional_special_tokens": [
|
3 |
+
"<|im_start|>",
|
4 |
+
"<|im_end|>"
|
5 |
+
],
|
6 |
+
"eos_token": {
|
7 |
+
"content": "<|im_end|>",
|
8 |
+
"lstrip": false,
|
9 |
+
"normalized": false,
|
10 |
+
"rstrip": false,
|
11 |
+
"single_word": false
|
12 |
+
},
|
13 |
+
"pad_token": {
|
14 |
+
"content": "<|endoftext|>",
|
15 |
+
"lstrip": false,
|
16 |
+
"normalized": false,
|
17 |
+
"rstrip": false,
|
18 |
+
"single_word": false
|
19 |
+
}
|
20 |
+
}
|
tokenizer_config.json
ADDED
@@ -0,0 +1,43 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"add_prefix_space": false,
|
3 |
+
"added_tokens_decoder": {
|
4 |
+
"151643": {
|
5 |
+
"content": "<|endoftext|>",
|
6 |
+
"lstrip": false,
|
7 |
+
"normalized": false,
|
8 |
+
"rstrip": false,
|
9 |
+
"single_word": false,
|
10 |
+
"special": true
|
11 |
+
},
|
12 |
+
"151644": {
|
13 |
+
"content": "<|im_start|>",
|
14 |
+
"lstrip": false,
|
15 |
+
"normalized": false,
|
16 |
+
"rstrip": false,
|
17 |
+
"single_word": false,
|
18 |
+
"special": true
|
19 |
+
},
|
20 |
+
"151645": {
|
21 |
+
"content": "<|im_end|>",
|
22 |
+
"lstrip": false,
|
23 |
+
"normalized": false,
|
24 |
+
"rstrip": false,
|
25 |
+
"single_word": false,
|
26 |
+
"special": true
|
27 |
+
}
|
28 |
+
},
|
29 |
+
"additional_special_tokens": [
|
30 |
+
"<|im_start|>",
|
31 |
+
"<|im_end|>"
|
32 |
+
],
|
33 |
+
"bos_token": null,
|
34 |
+
"chat_template": "{% for message in messages %}{% if loop.first and messages[0]['role'] != 'system' %}{{ '<|im_start|>system\nYou are a helpful assistant.<|im_end|>\n' }}{% endif %}{{'<|im_start|>' + message['role'] + '\n' + message['content'] + '<|im_end|>' + '\n'}}{% endfor %}{% if add_generation_prompt %}{{ '<|im_start|>assistant\n' }}{% endif %}",
|
35 |
+
"clean_up_tokenization_spaces": false,
|
36 |
+
"eos_token": "<|im_end|>",
|
37 |
+
"errors": "replace",
|
38 |
+
"model_max_length": 256000,
|
39 |
+
"pad_token": "<|endoftext|>",
|
40 |
+
"split_special_tokens": false,
|
41 |
+
"tokenizer_class": "Qwen2Tokenizer",
|
42 |
+
"unk_token": null
|
43 |
+
}
|
vocab.json
ADDED
The diff for this file is too large to render.
See raw diff
|
|