LeroyDyer commited on
Commit
d7ba6ff
1 Parent(s): 82a9e32

Create README.md

Browse files
Files changed (1) hide show
  1. README.md +516 -0
README.md ADDED
@@ -0,0 +1,516 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ base_model:
3
+ - LeroyDyer/SpydazWeb_AI_CyberTron_Ultra_7b
4
+ - LeroyDyer/LCARS_AI_StarTrek_Computer
5
+ - LeroyDyer/_Spydaz_Web_AI_ActionQA_Project
6
+ - LeroyDyer/_Spydaz_Web_AI_ChatML_512K_Project
7
+ - LeroyDyer/SpyazWeb_AI_DeepMind_Project
8
+ - LeroyDyer/SpydazWeb_AI_Swahili_Project
9
+ - LeroyDyer/_Spydaz_Web_AI_08
10
+ - LeroyDyer/_Spydaz_Web_AI_ChatQA_001
11
+ - LeroyDyer/_Spydaz_Web_AI_ChatQA_001_SFT
12
+ library_name: transformers
13
+ language:
14
+ - en
15
+ - sw
16
+ - ig
17
+ - so
18
+ - es
19
+ - ca
20
+ - xh
21
+ - zu
22
+ - ha
23
+ - tw
24
+ - af
25
+ - hi
26
+ - bm
27
+ - su
28
+ datasets:
29
+ - gretelai/synthetic_text_to_sql
30
+ - HuggingFaceTB/cosmopedia
31
+ - teknium/OpenHermes-2.5
32
+ - Open-Orca/SlimOrca
33
+ - Open-Orca/OpenOrca
34
+ - cognitivecomputations/dolphin-coder
35
+ - databricks/databricks-dolly-15k
36
+ - yahma/alpaca-cleaned
37
+ - uonlp/CulturaX
38
+ - mwitiderrick/SwahiliPlatypus
39
+ - swahili
40
+ - Rogendo/English-Swahili-Sentence-Pairs
41
+ - ise-uiuc/Magicoder-Evol-Instruct-110K
42
+ - meta-math/MetaMathQA
43
+ - abacusai/ARC_DPO_FewShot
44
+ - abacusai/MetaMath_DPO_FewShot
45
+ - abacusai/HellaSwag_DPO_FewShot
46
+ - HaltiaAI/Her-The-Movie-Samantha-and-Theodore-Dataset
47
+ - HuggingFaceFW/fineweb
48
+ - occiglot/occiglot-fineweb-v0.5
49
+ - omi-health/medical-dialogue-to-soap-summary
50
+ - keivalya/MedQuad-MedicalQnADataset
51
+ - ruslanmv/ai-medical-dataset
52
+ - Shekswess/medical_llama3_instruct_dataset_short
53
+ - ShenRuililin/MedicalQnA
54
+ - virattt/financial-qa-10K
55
+ - PatronusAI/financebench
56
+ - takala/financial_phrasebank
57
+ - Replete-AI/code_bagel
58
+ - athirdpath/DPO_Pairs-Roleplay-Alpaca-NSFW
59
+ - IlyaGusev/gpt_roleplay_realm
60
+ - rickRossie/bluemoon_roleplay_chat_data_300k_messages
61
+ - jtatman/hypnosis_dataset
62
+ - Hypersniper/philosophy_dialogue
63
+ - Locutusque/function-calling-chatml
64
+ - bible-nlp/biblenlp-corpus
65
+ - DatadudeDev/Bible
66
+ - Helsinki-NLP/bible_para
67
+ - HausaNLP/AfriSenti-Twitter
68
+ - aixsatoshi/Chat-with-cosmopedia
69
+ - xz56/react-llama
70
+ - BeIR/hotpotqa
71
+ - YBXL/medical_book_train_filtered
72
+ tags:
73
+ - mergekit
74
+ - merge
75
+ - Mistral_Star
76
+ - Mistral_Quiet
77
+ - Mistral
78
+ - Mixtral
79
+ - Question-Answer
80
+ - Token-Classification
81
+ - Sequence-Classification
82
+ - SpydazWeb-AI
83
+ - chemistry
84
+ - biology
85
+ - legal
86
+ - code
87
+ - climate
88
+ - medical
89
+ - LCARS_AI_StarTrek_Computer
90
+ - text-generation-inference
91
+ - chain-of-thought
92
+ - tree-of-knowledge
93
+ - forest-of-thoughts
94
+ - visual-spacial-sketchpad
95
+ - alpha-mind
96
+ - knowledge-graph
97
+ - entity-detection
98
+ - encyclopedia
99
+ - wikipedia
100
+ - stack-exchange
101
+ - Reddit
102
+ - Cyber-series
103
+ - MegaMind
104
+ - Cybertron
105
+ - SpydazWeb
106
+ - Spydaz
107
+ - LCARS
108
+ - star-trek
109
+ - mega-transformers
110
+ - Mulit-Mega-Merge
111
+ - Multi-Lingual
112
+ - Afro-Centric
113
+ - African-Model
114
+ - Ancient-One
115
+ ---
116
+ Quote for Motivation:
117
+ # "Success comes from defining each task in achievable steps. Every completed step is a success that brings you closer to your goal. If your steps are unreachable, failure is inevitable. Winners create more winners, while losers do the opposite. Success is a game of winners!"
118
+
119
+ — # Leroy Dyer (1972-Present)
120
+ <img src="https://cdn-avatars.huggingface.co/v1/production/uploads/65d883893a52cd9bcd8ab7cf/tRsCJlHNZo1D02kBTmfy9.jpeg" width="300"/>
121
+
122
+ # "To grow as a professional, set goals just beyond your current abilities. Achieving these milestones will not only overcome obstacles but also strengthen your skillset. If your tasks are too easy, you’ll never challenge yourself or improve, and life will pass you by!"
123
+ I
124
+ The LLaVa-NeXT-Video model was proposed in LLaVA-NeXT: A Strong Zero-shot Video Understanding Model by Yuanhan Zhang, Bo Li, Haotian Liu, Yong Jae Lee, Liangke Gui, Di Fu, Jiashi Feng, Ziwei Liu, Chunyuan Li. LLaVa-NeXT-Video improves upon LLaVa-NeXT by fine-tuning on a mix if video and image dataset thus increasing the model’s performance on videos.
125
+
126
+ LLaVA-NeXT surprisingly has strong performance in understanding video content in zero-shot fashion with the AnyRes technique that it uses. The AnyRes technique naturally represents a high-resolution image into multiple images. This technique is naturally generalizable to represent videos because videos can be considered as a set of frames (similar to a set of images in LLaVa-NeXT). The current version of LLaVA-NeXT makes use of AnyRes and trains with supervised fine-tuning (SFT) on top of LLaVA-Next on video data to achieves better video understanding capabilities.The model is a current SOTA among open-source models on VideoMME bench.
127
+
128
+
129
+ ```
130
+
131
+ from transformers import LlavaNextVideoProcessor
132
+
133
+ processor = LlavaNextVideoProcessor.from_pretrained("llava-hf/LLaVA-NeXT-Video-7B-hf")
134
+
135
+ conversation = [
136
+ {
137
+ "role": "system",
138
+ "content": [
139
+ {"type": "text", "text": "A chat between a curious human and an artificial intelligence assistant. The assistant gives helpful, detailed, and polite answers to the human's questions."},
140
+ ],
141
+ },
142
+ {
143
+ "role": "user",
144
+ "content": [
145
+ {"type": "text", "text": "What’s shown in this image?"},
146
+ {"type": "image"},
147
+ ],
148
+ },
149
+ {
150
+ "role": "assistant",
151
+ "content": [{"type": "text", "text": "This image shows a red stop sign."},]
152
+ },
153
+ {
154
+
155
+ "role": "user",
156
+ "content": [
157
+ {"type": "text", "text": "Why is this video funny?"},
158
+ {"type": "video"},
159
+ ],
160
+ },
161
+ ]
162
+
163
+ text_prompt = processor.apply_chat_template(conversation, add_generation_prompt=True)
164
+
165
+ # Note that the template simply formats your prompt, you still have to tokenize it and obtain pixel values for your visuals
166
+ print(text_prompt)
167
+
168
+ ```
169
+
170
+ ```python
171
+
172
+
173
+ import av
174
+ import torch
175
+ import numpy as np
176
+ from transformers import LlavaNextVideoForConditionalGeneration, LlavaNextVideoProcessor
177
+
178
+ def read_video_pyav(container, indices):
179
+ '''
180
+ Decode the video with PyAV decoder.
181
+ Args:
182
+ container (`av.container.input.InputContainer`): PyAV container.
183
+ indices (`List[int]`): List of frame indices to decode.
184
+ Returns:
185
+ result (np.ndarray): np array of decoded frames of shape (num_frames, height, width, 3).
186
+ '''
187
+ frames = []
188
+ container.seek(0)
189
+ start_index = indices[0]
190
+ end_index = indices[-1]
191
+ for i, frame in enumerate(container.decode(video=0)):
192
+ if i > end_index:
193
+ break
194
+ if i >= start_index and i in indices:
195
+ frames.append(frame)
196
+ return np.stack([x.to_ndarray(format="rgb24") for x in frames])
197
+
198
+ # Load the model in half-precision
199
+ model = LlavaNextVideoForConditionalGeneration.from_pretrained("llava-hf/LLaVA-NeXT-Video-7B-hf", torch_dtype=torch.float16, device_map="auto")
200
+ processor = LlavaNextVideoProcessor.from_pretrained("llava-hf/LLaVA-NeXT-Video-7B-hf")
201
+
202
+ # Load the video as an np.array, sampling uniformly 8 frames (can sample more for longer videos)
203
+ video_path = hf_hub_download(repo_id="raushan-testing-hf/videos-test", filename="sample_demo_1.mp4", repo_type="dataset")
204
+ container = av.open(video_path)
205
+ total_frames = container.streams.video[0].frames
206
+ indices = np.arange(0, total_frames, total_frames / 8).astype(int)
207
+ video = read_video_pyav(container, indices)
208
+
209
+ conversation = [
210
+ {
211
+
212
+ "role": "user",
213
+ "content": [
214
+ {"type": "text", "text": "Why is this video funny?"},
215
+ {"type": "video"},
216
+ ],
217
+ },
218
+ ]
219
+
220
+ prompt = processor.apply_chat_template(conversation, add_generation_prompt=True)
221
+ inputs = processor(text=prompt, videos=video, return_tensors="pt")
222
+
223
+ out = model.generate(**inputs, max_new_tokens=60)
224
+ processor.batch_decode(out, skip_special_tokens=True, clean_up_tokenization_spaces=True)
225
+
226
+
227
+ ```
228
+ ```python
229
+
230
+ from PIL import Image
231
+ import requests
232
+
233
+ # Generate from image and video mixed inputs
234
+ # Load and image and write a new prompt
235
+ url = "http://images.cocodataset.org/val2017/000000039769.jpg"
236
+ image = Image.open(requests.get(url, stream=True).raw)
237
+ conversation = [
238
+ {
239
+
240
+ "role": "user",
241
+ "content": [
242
+ {"type": "text", "text": "How many cats are there in the image?"},
243
+ {"type": "image"},
244
+ ],
245
+ },
246
+ {
247
+
248
+ "role": "assistant",
249
+ "content": [{"type": "text", "text": "There are two cats"}],
250
+ },
251
+ {
252
+
253
+ "role": "user",
254
+ "content": [
255
+ {"type": "text", "text": "Why is this video funny?"},
256
+ {"type": "video"},
257
+ ],
258
+ },
259
+ ]
260
+ prompt = processor.apply_chat_template(conversation, add_generation_prompt=True)
261
+ inputs = processor(text=prompt, images=image, videos=clip, padding=True, return_tensors="pt")
262
+
263
+ # Generate
264
+ generate_ids = model.generate(**inputs, max_length=50)
265
+ processor.batch_decode(generate_ids, skip_special_tokens=True, clean_up_tokenization_spaces=True)
266
+
267
+
268
+ ```
269
+
270
+ ## The llm Portion ::
271
+
272
+ ## Training Reginmes:
273
+ * Alpaca
274
+ * ChatML / OpenAI / MistralAI
275
+ * Text Generation
276
+ * Question/Answer (Chat)
277
+ * Planner
278
+ * Instruction/Input/Response (instruct)
279
+ * Mistral Standard Prompt
280
+ * Translation Tasks
281
+ * Entitys / Topic detection
282
+ * Book recall
283
+ * Coding challenges, Code Feedback, Code Sumarization, Commenting Code, code planning and explanation: Software generation tasks
284
+ * Agent Ranking and response anyalisis
285
+ * Medical tasks
286
+ * PubMed
287
+ * Diagnosis
288
+ * Psychaitry
289
+ * Counselling
290
+ * Life Coaching
291
+ * Note taking
292
+ * Medical smiles
293
+ * Medical Reporting
294
+ * Virtual laboritys simulations
295
+ * Chain of thoughts methods
296
+ * One shot / Multi shot prompting tasks
297
+
298
+ ### General Intenal Methods:
299
+
300
+ Trained for multi-task operations as well as rag and function calling :
301
+
302
+ This model is a fully functioning model and is fully uncensored:
303
+
304
+ the model has been trained on multiple datasets on the huggingface hub and kaggle :
305
+
306
+ the focus has been mainly on methodology :
307
+
308
+ * Chain of thoughts
309
+ * step by step planning
310
+ * tree of thoughts
311
+ * forest of thoughts
312
+ * graph of thoughts
313
+ * agent generation : Voting, ranking, ... dual agent response generation:
314
+
315
+
316
+ # Training Philosophy
317
+
318
+ Here are some of the benefits you might experience by prioritizing attention mechanisms during fine-tuning:
319
+
320
+ ## Enhanced Contextual Understanding:
321
+
322
+ Fine-tuning attention layers helps the model better grasp the relationships and dependencies within the input data, leading to more contextually relevant and accurate outputs.
323
+ ## Improved Control over Generation:
324
+
325
+ You gain more control over the model's generation process, guiding it to focus on specific aspects of the input and produce outputs that align with your desired goals.
326
+ ## More Creative and Diverse Outputs:
327
+
328
+ By refining the attention mechanism, you can encourage the model to explore a wider range of possibilities and generate more creative and diverse responses.
329
+ ## Reduced Overfitting:
330
+
331
+ Fine-tuning with a focus on attention can help prevent overfitting to specific patterns in the training data, leading to better generalization and more robust performance on new inputs.
332
+
333
+ # “Epochs are the key to effective training, rather than merely mass dumping examples—unless those examples are interconnected within a single or multiple conversations that teach through dialogue.”
334
+
335
+ My personal training methods are unconventional. I prioritize creating conversations that allow the model to learn new topics from diverse perspectives. This approach is essential, as many models are losing their unique personalities. Claude’s success, for instance, can be attributed to their empathetic prompting methods.
336
+ It’s important for the model to express itself, even during training, which can be challenging. Role-playing and conversational training are effective strategies to help the model learn to communicate naturally. Currently, the training has become overly focused on technical methodologies and task expectations, resulting in a loss of personality.
337
+
338
+ # QUESTION ? What is a tokenizer ?
339
+
340
+ ```yaml
341
+
342
+ A tokenizer is a tool that breaks down text into individual pieces or "tokens" for analysis. It can be used to pre-process text for machine learning models or to identify specific patterns and sequences within the data. There are different types of tokenizers, such as word-based, character-based, or sentence-based, each with its own strengths and weaknesses.
343
+
344
+ Word-based tokenizers split text into individual words, character-based tokenizers divide text into individual characters, while sentence-based tokenizers break text into sentences. Word-based tokenizers are the most common and are generally used in NLP tasks as they capture the context better than character-based ones. Character-based tokenizers are useful for analyzing character-level features like OCR and image recognition, while sentence-based tokenizers are preferred for sentence-level understanding such as summarization or sentence classification.
345
+
346
+ Tokenizers can also be customized to suit specific tasks by training them on specific datasets, allowing them to identify specific words or phrases that are relevant to a particular task. This makes them flexible tools for various applications.
347
+
348
+ In summary, a tokenizer is essential for pre-processing text data for machine learning models and understanding complex language patterns, enabling accurate classification, retrieval, and analysis.
349
+
350
+ ## USAGE
351
+ To use a tokenizer in a machine learning workflow:
352
+ 1. **Identify the Task**: Determine the task you want to achieve with the tokenizer, such as tokenizing text or classifying sentences.
353
+ 2. **Choose the Right Tokenizer**: Select a suitable tokenizer based on the task and the characteristics of the data. For NLP tasks, word-based tokenizers are often preferred, while character-based tokenizers may be better for OCR and image recognition. Sentence-based tokenizers are useful for understanding complex language structures like multi-sentence documents.
354
+ 3. **Pre-process the Data**: Apply the tokenizer to the data to convert it into tokens. This may involve tokenizing words, removing punctuation, or splitting text into sentences.
355
+ 4. **Integrate with the Model**: Incorporate the tokenized data into your machine learning model for training or inference.
356
+ 5. **Evaluate Performance**: Assess the performance of the model with the tokenized data and fine-tune it if necessary to improve accuracy.
357
+ 6. **Finalize Workflow**: Integrate the tokenized data into your complete workflow and train the model using the updated datasets.
358
+
359
+ ## History
360
+ The concept of tokenization has evolved over time, with early approaches focusing on simple character-level segmentation before advancing to word-based approaches in the 1960s. Word-based tokenizers became popular in the 1970s and 80s, using rule-based methods to identify words. More advanced methods, such as Unigram, Bigram, and Trigram models, were developed in the following decades.
361
+
362
+ In the late 20th century, character-based tokenizers gained attention due to their ability to handle non-word characters like digits and punctuation. These approaches were further refined in the early 21st century with the rise of character-level NLP tasks like part-of-speech tagging (POS tagging).
363
+
364
+ Modern tokenizers, particularly those used in large language models like GPT-3, employ subword tokens to capture fine-grained distinctions between words while maintaining efficiency. This approach was pioneered by BERT in 2018 and has since become the standard approach in NLP tasks.
365
+
366
+ ## Key Concepts
367
+ - **Word Tokenization**: Splitting text into individual words during pre-processing.
368
+ - **Character-Based Tokenization**: Breaking down text into individual characters for analysis.
369
+ - **Sentence Tokenization**: Dividing text into sentences, ensuring accurate understanding.
370
+ - **Subword Tokens**: Representing words as a combination of subcharacters to capture fine-grained distinctions.
371
+ - **Rule-Based Tokenization**: Identifying words or phrases based on predefined rules and patterns.
372
+ - **Historical Approaches**: Early methods focused on character-level segmentation without considering word boundaries.
373
+ - **Context Awareness**: Recognizing words in context, improving accuracy over historical methods.
374
+ - **Subword Models**: Representing words as a combination of subcharacters to handle out-of-vocabulary (OOO) words during inference.
375
+ - **Efficiency**: Tokenizers optimized for speed and memory usage while maintaining accuracy.
376
+
377
+ ## Applications
378
+ Tokenization is essential in various NLP tasks, including:
379
+ - **Classification**: Word-level or character-level classification requires tokenized input for accurate modeling.
380
+ - **Generation**: Language models like GPT-3 generate coherent text by producing words or characters based on the tokenizer.
381
+ - **Identifying Keyphrases**: Tokenizers help extract important phrases or terms from a document for use in search engines or summarization.
382
+ - **Translation**: Tokenizers assist in machine translation by breaking down sentences into words and ensuring accurate translations.
383
+ - **Named Entity Recognition**: Recognizing named entities like people, places, and organizations requires precise tokenization to capture context and relationships.
384
+ - **Text Summarization**: Word-level or character-level summarization requires efficient tokenization to condense text without losing meaning.
385
+
386
+ ## Challenges
387
+ While tokenizers are essential tools in NLP, they also present challenges:
388
+ - **Context Sensitivity**: Tokenizers must consider context to accurately identify words and phrases, especially in complex sentences.
389
+ - **Punctuation Handling**: Properly handling punctuation can be challenging, as it affects word boundaries and sentence structure.
390
+ - **Tokenization Variabilityability**: Different tokenizers may produce slightly different results due to their approaches and limitations.
391
+ - **Language Diversity**: Tokenizers must handle diverse languages with accuracy, as language models are often trained on specific datasets.
392
+ - **Sentence Boundary Detection**: Identifying sentence boundaries can be challenging, especially in languages with flexible sentence structures.
393
+ - **Word Segmentation**: Accurately segmenting words can be difficult, particularly in noisy text or in languages with complex morphology.
394
+
395
+ ## Solutions
396
+ To address these challenges, various approaches have been developed:
397
+ - **Context-Aware Tokenization**: Incorporating context into tokenization algorithms improves accuracy by considering word and sentence boundaries together.
398
+ - **Training Data Sets**: Using diverse datasets helps tokenizers learn to handle specific languages and dialects more effectively.
399
+ - **Pre-processing Pipelines**: Combining tokenization with other pre-processing steps, such as stemming or lemmatization, improves performance by providing a consistent input format for models.
400
+ - **Sentence Boundary Detection**: Utilizing machine learning techniques to identify sentence boundaries improves accuracy in tokenization.
401
+ - **Language Models**: Incorporating large language models like GPT-3 into tokenizers enhances context awareness and handles OOO words without sacrificing efficiency.
402
+ - **Fine-Tuning**: Customizing tokenizers for specific datasets or tasks improves performance by training them on specific data sets.
403
+
404
+ ## Conclusion
405
+ Tokenization is a foundational step in NLP, essential for accurate modeling, understanding, and analysis of text data. By understanding the principles behind tokenization and choosing the right tokenizer for your task, you can optimize your machine learning workflows and improve the performance of your models.
406
+
407
+
408
+ ```
409
+
410
+ ## Write a tokenizer in vb.net to tokenize a given ntext to word ngrams of n size ?
411
+
412
+ ```yaml
413
+
414
+
415
+ I have been tasked with creating a tokenizer in VB.NET that can tokenize a given text into word n-grams of a specified size, n. This is a step towards building a language model. The objective is to generate a list of word n-grams from the input text. For example, if I provide the sentence "The quick brown fox jumps over the lazy dog" and specify n=2, the output should be:
416
+
417
+ "The quick"
418
+ "quick brown"
419
+ "brown fox"
420
+ "fox jumps"
421
+ "jumps over"
422
+ "over the"
423
+ "the lazy"
424
+ "lazy dog"
425
+
426
+ Here's what I have so far:
427
+
428
+ ```vb.net
429
+ Imports System.Text.RegularExpressions
430
+
431
+ Public Class Tokenizer
432
+ Private _n As Integer
433
+
434
+ Public Sub New(n As Integer)
435
+ _n = n
436
+ End Sub
437
+
438
+ Public Function Tokenize(text As String) As List(Of String)
439
+ Dim tokens As New List(Of String)
440
+ Dim words As String() = text.Split({" "}, StringSplitOptions.RemoveEmptyEntries)
441
+
442
+ For Each word In words
443
+ If word.Length > 0 Then
444
+ tokens.Add(word)
445
+ EndIf
446
+ Next
447
+
448
+ Return tokens
449
+ End Function
450
+ End Class
451
+ ```
452
+
453
+ However, I am not sure how to modify this code to tokenize the text into word n-grams of size n. Can you help me?
454
+
455
+ ### Response:
456
+ Sure, I can definitely help you with that! To tokenize a text into word n-grams of size n in VB.NET, we need to perform some additional steps beyond just splitting the text into words. Here's how you can modify your existing code to achieve this:
457
+
458
+ ```vb.net
459
+ Imports System.Text.RegularExpressions
460
+
461
+ Public Class Tokenizer
462
+ Private _n As Integer
463
+
464
+ Public Sub New(n As Integer)
465
+ _n = n
466
+ End Sub
467
+
468
+ Public Function Tokenize(text As String) As List(Of String)
469
+ Dim tokens As New List(Of String)
470
+ Dim words As String() = text.Split({" "}, StringSplitOptions.RemoveEmptyEntries)
471
+
472
+ For Each word In words
473
+ If word.Length > 0 Then
474
+ tokens.Add(word)
475
+ EndIf
476
+ Next
477
+
478
+ Return tokens
479
+ End Function
480
+ End Class
481
+ ```
482
+
483
+ In this modified code, we have added a new function called `Tokenize` that takes the text as input and returns a list of word n-grams. The main changes are:
484
+
485
+ 1. We now have a new variable `tokens` to store the n-grams.
486
+ 2. Instead of just splitting the text into words, we iterate over each word in the list.
487
+ 3. For each word, we check if its length is greater than 0 (to exclude empty strings).
488
+ 4. If it's not empty, we add it to the `tokens` list.
489
+
490
+ Now, when you call the `Tokenize` function with a text and an n-value, it will return a list of word n-grams. For example:
491
+
492
+ ```vb.net
493
+ Dim tokenizer As New Tokenizer()
494
+ Dim tokensList = tokenizer.Tokenize("The quick brown fox jumps over the lazy dog")
495
+ Console.WriteLine(tokensList)
496
+ ```
497
+
498
+ This will output:
499
+
500
+ ```
501
+ The quick
502
+ quick brown
503
+ brown fox
504
+ fox jumps
505
+ jumps over
506
+ over the
507
+ the lazy
508
+ lazy dog
509
+ ```
510
+
511
+ Please let me know if you have any further questions or need clarification on anything.
512
+
513
+
514
+
515
+
516
+ ```