Text Generation
Safetensors
Swedish
qwen3
qwrt commited on
Commit
64a1a75
·
verified ·
1 Parent(s): 095b98f

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +41 -1
README.md CHANGED
@@ -7,7 +7,7 @@ pipeline_tag: text-classification
7
 
8
  **Overview**
9
 
10
- This is a 1.1M parameter language model, using Qwen3 architecrue, pretrained 10 epochs on a textdataset consisting av 7 billion characters of swedish books. It uses utf-8 byte level encoding, so it basically sees
11
  and generates individual characters instead of word groups. More specific characters like "åäö" and emojis are represented with more than one token in the utf8 encoding.
12
  Due to the model's size, it is not made for generating meaningful text.
13
  ![träningsloss-v1](https://cdn-uploads.huggingface.co/production/uploads/635e974b0ddaddda094cd868/HWBtJOuOhPd0yEe6m8L2D.png)
@@ -83,8 +83,48 @@ For example, 99.9% of the top 20 000 words used by the model are real words.
83
 
84
 
85
 
 
86
 
 
 
 
 
 
 
 
 
 
 
 
 
 
87
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
88
 
89
 
90
  Do whatever with the model.
 
7
 
8
  **Overview**
9
 
10
+ This is a 1.1M parameter language model, using Qwen3 architecrue, pretrained 10 epochs on a textdataset consisting of 7 billion characters of swedish books. It uses utf-8 byte level encoding, so it basically sees
11
  and generates individual characters instead of word groups. More specific characters like "åäö" and emojis are represented with more than one token in the utf8 encoding.
12
  Due to the model's size, it is not made for generating meaningful text.
13
  ![träningsloss-v1](https://cdn-uploads.huggingface.co/production/uploads/635e974b0ddaddda094cd868/HWBtJOuOhPd0yEe6m8L2D.png)
 
83
 
84
 
85
 
86
+ **Converting a text to a number**
87
 
88
+ Using the model, it can analyse a text in swedish and based on the predictability on the letters make a number.
89
+ ```python
90
+ from huggingface_hub import hf_hub_download
91
+ import importlib.util
92
+ from transformers import Qwen3ForCausalLM
93
+ import torch
94
+
95
+ repo="qwrt/Swedish1M"
96
+
97
+ file_path = hf_hub_download(
98
+ repo_id=repo,
99
+ filename="textnumberlib.py"
100
+ )
101
 
102
+ spec = importlib.util.spec_from_file_location("textnumberlib", file_path)
103
+ modul = importlib.util.module_from_spec(spec)
104
+ spec.loader.exec_module(modul)
105
+
106
+ device = "cuda" if torch.cuda.is_available() else "cpu"
107
+ model = Qwen3ForCausalLM.from_pretrained(repo).to(device)
108
+
109
+ text="""En specifik text"""
110
+ combined=modul.text_to_bits("\n"+text, model, device)
111
+ number=modul.bits_to_tal(combined)
112
+ print(number)
113
+ ```
114
+ ```
115
+ 29131937837
116
+ ```
117
+
118
+ To convert the number back to a text:
119
+ ```python
120
+ number=29131937837
121
+
122
+ bits=modul.bits_from_tal(number)
123
+ text=modul.bits_to_text("\n", bits, 50, model, device, write=True).replace("\n", "⏎")
124
+ ```
125
+ ```
126
+ En specifik text som hade skrivits ut var en stor
127
+ ```
128
 
129
 
130
  Do whatever with the model.