litgpt 0.4.0.dev0__tar.gz → 0.4.2__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 (98) hide show
  1. {litgpt-0.4.0.dev0 → litgpt-0.4.2}/PKG-INFO +165 -135
  2. {litgpt-0.4.0.dev0 → litgpt-0.4.2}/README.md +161 -132
  3. {litgpt-0.4.0.dev0 → litgpt-0.4.2}/litgpt/__init__.py +2 -1
  4. litgpt-0.4.2/litgpt/api.py +293 -0
  5. {litgpt-0.4.0.dev0 → litgpt-0.4.2}/litgpt/args.py +8 -0
  6. {litgpt-0.4.0.dev0 → litgpt-0.4.2}/litgpt/chat/base.py +4 -1
  7. {litgpt-0.4.0.dev0 → litgpt-0.4.2}/litgpt/config.py +36 -0
  8. {litgpt-0.4.0.dev0 → litgpt-0.4.2}/litgpt/deploy/serve.py +6 -5
  9. {litgpt-0.4.0.dev0 → litgpt-0.4.2}/litgpt/eval/evaluate.py +6 -2
  10. {litgpt-0.4.0.dev0 → litgpt-0.4.2}/litgpt/finetune/adapter.py +19 -9
  11. {litgpt-0.4.0.dev0 → litgpt-0.4.2}/litgpt/finetune/adapter_v2.py +19 -9
  12. {litgpt-0.4.0.dev0 → litgpt-0.4.2}/litgpt/finetune/full.py +20 -16
  13. {litgpt-0.4.0.dev0 → litgpt-0.4.2}/litgpt/finetune/lora.py +19 -9
  14. {litgpt-0.4.0.dev0 → litgpt-0.4.2}/litgpt/generate/adapter.py +8 -1
  15. {litgpt-0.4.0.dev0 → litgpt-0.4.2}/litgpt/generate/adapter_v2.py +8 -1
  16. {litgpt-0.4.0.dev0 → litgpt-0.4.2}/litgpt/generate/base.py +17 -3
  17. {litgpt-0.4.0.dev0 → litgpt-0.4.2}/litgpt/generate/full.py +9 -2
  18. {litgpt-0.4.0.dev0 → litgpt-0.4.2}/litgpt/generate/sequentially.py +7 -0
  19. {litgpt-0.4.0.dev0 → litgpt-0.4.2}/litgpt/generate/tp.py +7 -0
  20. {litgpt-0.4.0.dev0 → litgpt-0.4.2}/litgpt/pretrain.py +20 -10
  21. {litgpt-0.4.0.dev0 → litgpt-0.4.2}/litgpt/prompts.py +45 -8
  22. {litgpt-0.4.0.dev0 → litgpt-0.4.2}/litgpt/scripts/convert_hf_checkpoint.py +8 -0
  23. {litgpt-0.4.0.dev0 → litgpt-0.4.2}/litgpt/scripts/download.py +9 -3
  24. {litgpt-0.4.0.dev0 → litgpt-0.4.2}/litgpt/scripts/merge_lora.py +7 -1
  25. {litgpt-0.4.0.dev0 → litgpt-0.4.2}/litgpt/tokenizer.py +21 -13
  26. {litgpt-0.4.0.dev0 → litgpt-0.4.2}/litgpt/utils.py +27 -8
  27. {litgpt-0.4.0.dev0 → litgpt-0.4.2}/litgpt.egg-info/PKG-INFO +165 -135
  28. {litgpt-0.4.0.dev0 → litgpt-0.4.2}/litgpt.egg-info/SOURCES.txt +2 -0
  29. {litgpt-0.4.0.dev0 → litgpt-0.4.2}/litgpt.egg-info/requires.txt +3 -2
  30. {litgpt-0.4.0.dev0 → litgpt-0.4.2}/pyproject.toml +4 -3
  31. litgpt-0.4.2/tests/test_api.py +104 -0
  32. {litgpt-0.4.0.dev0 → litgpt-0.4.2}/tests/test_evaluate.py +30 -2
  33. {litgpt-0.4.0.dev0 → litgpt-0.4.2}/tests/test_pretrain.py +1 -1
  34. {litgpt-0.4.0.dev0 → litgpt-0.4.2}/tests/test_prompts.py +77 -0
  35. {litgpt-0.4.0.dev0 → litgpt-0.4.2}/tests/test_readme.py +15 -12
  36. {litgpt-0.4.0.dev0 → litgpt-0.4.2}/tests/test_serve.py +1 -1
  37. {litgpt-0.4.0.dev0 → litgpt-0.4.2}/tests/test_tokenizer.py +6 -4
  38. {litgpt-0.4.0.dev0 → litgpt-0.4.2}/tests/test_utils.py +26 -0
  39. {litgpt-0.4.0.dev0 → litgpt-0.4.2}/LICENSE +0 -0
  40. {litgpt-0.4.0.dev0 → litgpt-0.4.2}/litgpt/__main__.py +0 -0
  41. {litgpt-0.4.0.dev0 → litgpt-0.4.2}/litgpt/adapter.py +0 -0
  42. {litgpt-0.4.0.dev0 → litgpt-0.4.2}/litgpt/adapter_v2.py +0 -0
  43. {litgpt-0.4.0.dev0 → litgpt-0.4.2}/litgpt/chat/__init__.py +0 -0
  44. {litgpt-0.4.0.dev0 → litgpt-0.4.2}/litgpt/data/__init__.py +0 -0
  45. {litgpt-0.4.0.dev0 → litgpt-0.4.2}/litgpt/data/alpaca.py +0 -0
  46. {litgpt-0.4.0.dev0 → litgpt-0.4.2}/litgpt/data/alpaca_2k.py +0 -0
  47. {litgpt-0.4.0.dev0 → litgpt-0.4.2}/litgpt/data/alpaca_gpt4.py +0 -0
  48. {litgpt-0.4.0.dev0 → litgpt-0.4.2}/litgpt/data/base.py +0 -0
  49. {litgpt-0.4.0.dev0 → litgpt-0.4.2}/litgpt/data/deita.py +0 -0
  50. {litgpt-0.4.0.dev0 → litgpt-0.4.2}/litgpt/data/dolly.py +0 -0
  51. {litgpt-0.4.0.dev0 → litgpt-0.4.2}/litgpt/data/flan.py +0 -0
  52. {litgpt-0.4.0.dev0 → litgpt-0.4.2}/litgpt/data/json_data.py +0 -0
  53. {litgpt-0.4.0.dev0 → litgpt-0.4.2}/litgpt/data/lima.py +0 -0
  54. {litgpt-0.4.0.dev0 → litgpt-0.4.2}/litgpt/data/lit_data.py +0 -0
  55. {litgpt-0.4.0.dev0 → litgpt-0.4.2}/litgpt/data/longform.py +0 -0
  56. {litgpt-0.4.0.dev0 → litgpt-0.4.2}/litgpt/data/microllama.py +0 -0
  57. {litgpt-0.4.0.dev0 → litgpt-0.4.2}/litgpt/data/openwebtext.py +0 -0
  58. {litgpt-0.4.0.dev0 → litgpt-0.4.2}/litgpt/data/prepare_slimpajama.py +0 -0
  59. {litgpt-0.4.0.dev0 → litgpt-0.4.2}/litgpt/data/prepare_starcoder.py +0 -0
  60. {litgpt-0.4.0.dev0 → litgpt-0.4.2}/litgpt/data/text_files.py +0 -0
  61. {litgpt-0.4.0.dev0 → litgpt-0.4.2}/litgpt/data/tinyllama.py +0 -0
  62. {litgpt-0.4.0.dev0 → litgpt-0.4.2}/litgpt/data/tinystories.py +0 -0
  63. {litgpt-0.4.0.dev0 → litgpt-0.4.2}/litgpt/deploy/__init__.py +0 -0
  64. {litgpt-0.4.0.dev0 → litgpt-0.4.2}/litgpt/finetune/__init__.py +0 -0
  65. {litgpt-0.4.0.dev0 → litgpt-0.4.2}/litgpt/generate/__init__.py +0 -0
  66. {litgpt-0.4.0.dev0 → litgpt-0.4.2}/litgpt/lora.py +0 -0
  67. {litgpt-0.4.0.dev0 → litgpt-0.4.2}/litgpt/model.py +0 -0
  68. {litgpt-0.4.0.dev0 → litgpt-0.4.2}/litgpt/scripts/__init__.py +0 -0
  69. {litgpt-0.4.0.dev0 → litgpt-0.4.2}/litgpt/scripts/convert_lit_checkpoint.py +0 -0
  70. {litgpt-0.4.0.dev0 → litgpt-0.4.2}/litgpt/scripts/convert_pretrained_checkpoint.py +0 -0
  71. {litgpt-0.4.0.dev0 → litgpt-0.4.2}/litgpt.egg-info/dependency_links.txt +0 -0
  72. {litgpt-0.4.0.dev0 → litgpt-0.4.2}/litgpt.egg-info/entry_points.txt +0 -0
  73. {litgpt-0.4.0.dev0 → litgpt-0.4.2}/litgpt.egg-info/top_level.txt +0 -0
  74. {litgpt-0.4.0.dev0 → litgpt-0.4.2}/setup.cfg +0 -0
  75. {litgpt-0.4.0.dev0 → litgpt-0.4.2}/tests/test_adapter.py +0 -0
  76. {litgpt-0.4.0.dev0 → litgpt-0.4.2}/tests/test_adapter_v2.py +0 -0
  77. {litgpt-0.4.0.dev0 → litgpt-0.4.2}/tests/test_args.py +0 -0
  78. {litgpt-0.4.0.dev0 → litgpt-0.4.2}/tests/test_chat.py +0 -0
  79. {litgpt-0.4.0.dev0 → litgpt-0.4.2}/tests/test_ci.py +0 -0
  80. {litgpt-0.4.0.dev0 → litgpt-0.4.2}/tests/test_cli.py +0 -0
  81. {litgpt-0.4.0.dev0 → litgpt-0.4.2}/tests/test_config.py +0 -0
  82. {litgpt-0.4.0.dev0 → litgpt-0.4.2}/tests/test_config_hub.py +0 -0
  83. {litgpt-0.4.0.dev0 → litgpt-0.4.2}/tests/test_convert_hf_checkpoint.py +0 -0
  84. {litgpt-0.4.0.dev0 → litgpt-0.4.2}/tests/test_convert_lit_checkpoint.py +0 -0
  85. {litgpt-0.4.0.dev0 → litgpt-0.4.2}/tests/test_convert_pretrained_checkpoint.py +0 -0
  86. {litgpt-0.4.0.dev0 → litgpt-0.4.2}/tests/test_full.py +0 -0
  87. {litgpt-0.4.0.dev0 → litgpt-0.4.2}/tests/test_generate.py +0 -0
  88. {litgpt-0.4.0.dev0 → litgpt-0.4.2}/tests/test_generate_adapter.py +0 -0
  89. {litgpt-0.4.0.dev0 → litgpt-0.4.2}/tests/test_generate_sequentially.py +0 -0
  90. {litgpt-0.4.0.dev0 → litgpt-0.4.2}/tests/test_generate_tp.py +0 -0
  91. {litgpt-0.4.0.dev0 → litgpt-0.4.2}/tests/test_lora.py +0 -0
  92. {litgpt-0.4.0.dev0 → litgpt-0.4.2}/tests/test_merge_lora.py +0 -0
  93. {litgpt-0.4.0.dev0 → litgpt-0.4.2}/tests/test_model.py +0 -0
  94. {litgpt-0.4.0.dev0 → litgpt-0.4.2}/tests/test_rope.py +0 -0
  95. {litgpt-0.4.0.dev0 → litgpt-0.4.2}/tests/test_thunder_ddp.py +0 -0
  96. {litgpt-0.4.0.dev0 → litgpt-0.4.2}/tests/test_thunder_fsdp.py +0 -0
  97. {litgpt-0.4.0.dev0 → litgpt-0.4.2}/tests/test_thunder_pretrain.py +0 -0
  98. {litgpt-0.4.0.dev0 → litgpt-0.4.2}/tests/test_unsloth_executor.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: litgpt
3
- Version: 0.4.0.dev0
3
+ Version: 0.4.2
4
4
  Summary: Hackable implementation of state-of-the-art open-source LLMs
5
5
  Author-email: Lightning AI <contact@lightning.ai>
6
6
  License: Apache License
@@ -220,15 +220,16 @@ Requires-Dist: pytest-dependency>=0.6.0; extra == "test"
220
220
  Requires-Dist: transformers>=4.38.0; extra == "test"
221
221
  Requires-Dist: einops>=0.7.0; extra == "test"
222
222
  Requires-Dist: protobuf>=4.23.4; extra == "test"
223
- Requires-Dist: lightning-thunder==0.2.0.dev20240505; python_version >= "3.10" and extra == "test"
223
+ Requires-Dist: lightning-thunder==0.2.0.dev20240623; python_version >= "3.10" and extra == "test"
224
224
  Provides-Extra: all
225
225
  Requires-Dist: bitsandbytes==0.42.0; extra == "all"
226
226
  Requires-Dist: sentencepiece>=0.2.0; extra == "all"
227
227
  Requires-Dist: tokenizers>=0.15.2; extra == "all"
228
228
  Requires-Dist: requests>=2.31.0; extra == "all"
229
229
  Requires-Dist: litdata==0.2.6; extra == "all"
230
- Requires-Dist: litserve==0.1.1dev0; extra == "all"
230
+ Requires-Dist: litserve>=0.1.2; extra == "all"
231
231
  Requires-Dist: zstandard>=0.22.0; extra == "all"
232
+ Requires-Dist: numpy<2.0.0; extra == "all"
232
233
  Requires-Dist: pandas>=1.9.0; extra == "all"
233
234
  Requires-Dist: pyarrow>=15.0.2; extra == "all"
234
235
  Requires-Dist: tensorboard>=2.14.0; extra == "all"
@@ -244,13 +245,13 @@ Requires-Dist: huggingface_hub[hf_transfer]>=0.21.0; extra == "all"
244
245
 
245
246
  # ⚡ LitGPT
246
247
 
247
- **Pretrain, finetune, evaluate, and deploy 20+ LLMs on your own data**
248
+ **Load, finetune, pretrain, evaluate, and deploy 20+ LLMs on your own data**
248
249
 
249
250
  Uses the latest state-of-the-art techniques:
250
251
 
251
252
  <pre>
252
- ✅ flash attention ✅ fp4/8/16/32 ✅ LoRA, QLoRA, Adapter
253
- ✅ FSDP ✅ 1-1000+ GPUs/TPUs ✅ 20+ LLMs
253
+ Scratch implementations ✅ flash attention ✅ fp4/8/16/32 ✅ LoRA, QLoRA, Adapter
254
+ No abstractions ✅ FSDP ✅ 1-1000+ GPUs/TPUs ✅ 20+ LLMs
254
255
  </pre>
255
256
 
256
257
 
@@ -262,14 +263,13 @@ Uses the latest state-of-the-art techniques:
262
263
 
263
264
  <p align="center">
264
265
  <a href="https://lightning.ai/">Lightning AI</a> •
265
- <a href="#choose-from-20-llms">Models</a> •
266
266
  <a href="#quick-start">Quick start</a> •
267
- <a href="#use-an-llm-for-inference">Inference</a> •
268
- <a href="#finetune-an-llm">Finetune</a> •
269
- <a href="#finetune-an-llm">Pretrain</a> •
267
+ <a href="#choose-from-20-llms">Models</a> •
268
+ <a href="#finetune-an-llm">Finetune/pretrain</a> •
270
269
  <a href="#deploy-an-llm">Deploy</a> •
271
270
  <a href="#state-of-the-art-features">Features</a> •
272
- <a href="#training-recipes">Training recipes (YAML)</a>
271
+ <a href="#training-recipes">Training recipes (YAML)</a>
272
+ <a href="#tutorials">Tutorials</a>
273
273
  </p>
274
274
 
275
275
  </div>
@@ -278,15 +278,63 @@ Uses the latest state-of-the-art techniques:
278
278
  <img src="https://pl-bolts-doc-images.s3.us-east-2.amazonaws.com/GithubLitGPTDAG2.png" alt="LitGPT steps" width="auto"/>
279
279
  &nbsp;
280
280
 
281
- # Finetune, pretrain and deploy LLMs Lightning fast ⚡⚡
282
- LitGPT is a command-line tool designed to easily [finetune](#finetune-an-llm), [pretrain](#pretrain-an-llm), [evaluate](#use-an-llm), and [deploy](#deploy-an-llm) [20+ LLMs](#choose-from-20-llms) **on your own data**. It features highly-optimized [training recipes](#training-recipes) for the world's most powerful open-source large language models (LLMs).
281
+ # Load, finetune, pretrain, deploy LLMs Lightning fast ⚡⚡
282
+ LitGPT is a library of **lightning-fast** large language model (LLMs) **implemented from scratch** (Apache 2.0) with **no abstractions**.
283
283
 
284
284
  We reimplemented all model architectures and training recipes from scratch for 4 reasons:
285
285
 
286
- 1. Remove all abstraction layers and have single file implementations.
287
- 2. Guarantee Apache 2.0 compliance to enable enterprise use without limits.
288
- 3. Optimized each model's architectural detail to maximize performance, reduce costs, and speed up training.
289
- 4. Highly-optimized [recipe configs](#training-recipes) we have tested at enterprise scale.
286
+ Apache 2.0 compliance to enable unlimited enterprise use.
287
+ Easy debugging/hacking with no abstraction layers and single file implementations.
288
+ Optimized model architectures to maximize performance, reduce costs, and speed up training.
289
+ Highly-optimized [recipe configs](#training-recipes) we have tested at enterprise scale.
290
+
291
+ In addition to a simple Python API, it offers a command-line tool designed to easily [finetune](#finetune-an-llm), [pretrain](#pretrain-an-llm), [evaluate](#use-an-llm), and [deploy](#deploy-an-llm) [20+ LLMs](#choose-from-20-llms) **on your own data**. It features highly-optimized [training recipes](#training-recipes) for the world's most powerful open-source large language models (LLMs).
292
+
293
+ &nbsp;
294
+
295
+ # Quick start
296
+ Install LitGPT
297
+ ```
298
+ pip install 'litgpt[all]'
299
+ ```
300
+
301
+ Load and use any of the [20+ LLMs](#choose-from-20-llms):
302
+ ```python
303
+ from litgpt import LLM
304
+
305
+ llm = LLM.load("microsoft/phi-2")
306
+ text = llm.generate("Correct the spelling: Every summer, the familly enjoys a trip to the mountains.")
307
+ print(text)
308
+ # Corrected Sentence: Every summer, the family enjoys a vacation to the mountains.
309
+ ```
310
+
311
+ > [!NOTE]
312
+ > **[Explore the Python API options](tutorials/python-api.md)**.
313
+
314
+ &nbsp;
315
+ &nbsp;
316
+
317
+ ✅ Optimized for fast inference
318
+ ✅ Quantization
319
+ ✅ Runs on low-memory GPUs
320
+ ✅ No layers of internal abstractions
321
+ ✅ Optimized for production scale
322
+
323
+ &nbsp;
324
+
325
+ <details>
326
+ <summary>Advanced install options</summary>
327
+
328
+ &nbsp;
329
+
330
+ Install from source:
331
+
332
+ ```bash
333
+ git clone https://github.com/Lightning-AI/litgpt
334
+ cd litgpt
335
+ pip install -e '.[all]'
336
+ ```
337
+ </details>
290
338
 
291
339
  ---
292
340
 
@@ -345,40 +393,21 @@ LitGPT has 🤯 **custom, from-scratch implementations** of [20+ LLMs](tutorials
345
393
 
346
394
  </details>
347
395
 
348
- &nbsp;
349
-
350
- ## Install LitGPT
351
-
352
- Install LitGPT with all dependencies (including CLI, quantization, tokenizers for all models, etc.):
353
-
354
- ```bash
355
- pip install 'litgpt[all]'
356
- ```
357
-
358
- <details>
359
- <summary>Advanced install options</summary>
396
+ ---
360
397
 
361
398
  &nbsp;
362
399
 
363
- Install from source:
364
-
365
- ```bash
366
- git clone https://github.com/Lightning-AI/litgpt
367
- cd litgpt
368
- pip install -e '.[all]'
369
- ```
370
- </details>
371
-
372
- ---
400
+ # Advanced workflows
401
+ Use the command line interface to run advanced workflows such as pretraining or finetuning on your own data.
373
402
 
374
- &nbsp;
375
- # Quick start
403
+ ## All commands
376
404
  After installing LitGPT, select the model and action you want to take on that model (finetune, pretrain, evaluate, deploy, etc...):
377
405
 
378
406
  ```bash
379
407
  # ligpt [action] [model]
380
408
  litgpt download meta-llama/Meta-Llama-3-8B-Instruct
381
409
  litgpt chat meta-llama/Meta-Llama-3-8B-Instruct
410
+ litgpt evaluate meta-llama/Meta-Llama-3-8B-Instruct
382
411
  litgpt finetune meta-llama/Meta-Llama-3-8B-Instruct
383
412
  litgpt pretrain meta-llama/Meta-Llama-3-8B-Instruct
384
413
  litgpt serve meta-llama/Meta-Llama-3-8B-Instruct
@@ -386,34 +415,6 @@ litgpt serve meta-llama/Meta-Llama-3-8B-Instruct
386
415
 
387
416
  &nbsp;
388
417
 
389
- ### Use an LLM for inference
390
- Use LLMs for inference to test its chatting capabilities, run evaluations, or extract embeddings, etc.
391
- Here's an example showing how to use the Phi-2 LLM.
392
-
393
- <a target="_blank" href="https://lightning.ai/lightning-ai/studios/litgpt-chat">
394
- <img src="https://pl-bolts-doc-images.s3.us-east-2.amazonaws.com/app-2/studio-badge.svg" alt="Open In Studio"/>
395
- </a>
396
-
397
- &nbsp;
398
-
399
- ```bash
400
- # 1) List all available models in litgpt
401
- litgpt download list
402
-
403
- # 2) Download a pretrained model
404
- litgpt download microsoft/phi-2
405
-
406
- # 3) Chat with the model
407
- litgpt chat microsoft/phi-2
408
-
409
- >> Prompt: What do Llamas eat?
410
- ```
411
-
412
- The download of certain models requires an additional access token. You can read more about this in the [download](tutorials/download_model_weights.md#specific-models-and-access-tokens) documentation.
413
- For more information on the different inference options, refer to the [inference](tutorials/inference.md) tutorial.
414
-
415
- &nbsp;
416
-
417
418
  ### Finetune an LLM
418
419
  [Finetune](tutorials/finetune.md) a model to specialize it on your own custom dataset:
419
420
 
@@ -443,7 +444,8 @@ litgpt chat out/custom-model/final
443
444
  &nbsp;
444
445
 
445
446
  ### Pretrain an LLM
446
- Train an LLM from scratch on your own data via pretraining:
447
+
448
+ [Train an LLM from scratch](tutorials/pretrain.md) on your own data via pretraining:
447
449
 
448
450
  <a target="_blank" href="https://lightning.ai/lightning-ai/studios/litgpt-pretrain">
449
451
  <img src="https://pl-bolts-doc-images.s3.us-east-2.amazonaws.com/app-2/studio-badge.svg"; alt="Open In Studio"/>
@@ -475,7 +477,8 @@ litgpt chat out/custom-model/final
475
477
  &nbsp;
476
478
 
477
479
  ### Continue pretraining an LLM
478
- This is another way of finetuning that specializes an already pretrained model by training on custom data:
480
+
481
+ [Continued pretraining](tutorials/pretrain.md#continued-pretraining-on-custom-data) is another way of finetuning that specializes an already pretrained model by training on custom data:
479
482
 
480
483
 
481
484
  <a target="_blank" href="https://lightning.ai/lightning-ai/studios/litgpt-continue-pretraining">
@@ -507,8 +510,21 @@ litgpt chat out/custom-model/final
507
510
 
508
511
  &nbsp;
509
512
 
513
+ ### Evaluate an LLM
514
+
515
+ If you want to [evaluate](tutorials/evaluation.md) a downloaded, finetuned, or pretrained LLM on popular benchmark tasks, such as MMLU and Truthful QA, run the following command:
516
+
517
+ ```bash
518
+ litgpt evaluate microsoft/phi-2 --tasks 'truthfulqa_mc2,mmlu'
519
+ ```
520
+
521
+ > [!NOTE]
522
+ > **[Read the evaluation docs](tutorials/evaluation.md)** for more options.
523
+
524
+ &nbsp;
525
+
510
526
  ### Deploy an LLM
511
- Once you're ready to deploy a finetuned LLM, run this command:
527
+ Once you're ready to [deploy](tutorials/deploy.md) a finetuned LLM, run this command:
512
528
 
513
529
  <a target="_blank" href="https://lightning.ai/lightning-ai/studios/litgpt-serve">
514
530
  <img src="https://pl-bolts-doc-images.s3.us-east-2.amazonaws.com/app-2/studio-badge.svg" alt="Open In Studio"/>
@@ -527,25 +543,55 @@ litgpt serve microsoft/phi-2
527
543
 
528
544
  Test the server in a separate terminal and integrate the model API into your AI product:
529
545
  ```python
530
- # 3) Use the server (in a separate session)
546
+ # 3) Use the server (in a separate Python session)
531
547
  import requests, json
532
- response = requests.post(
533
- "http://127.0.0.1:8000/predict",
534
- json={"prompt": "Fix typos in the following sentence: Exampel input"}
548
+ response = requests.post(
549
+ "http://127.0.0.1:8000/predict",
550
+ json={"prompt": "Fix typos in the following sentence: Exampel input"}
535
551
  )
536
552
  print(response.json()["output"])
537
553
  ```
538
554
 
539
- &nbsp;
540
555
 
541
556
  > [!NOTE]
542
- > **[Read the full docs](tutorials/0_to_litgpt.md)**.
557
+ > **[Read the full docs](tutorials/deploy.md)**.
543
558
 
544
559
  &nbsp;
545
560
 
546
561
  ----
547
562
 
563
+ ### Use an LLM for inference
564
+
565
+ Use LLMs for [inference](tutorials/deploy.md) to test its chatting capabilities, run evaluations, or extract embeddings, etc.
566
+ Here's an example showing how to use the Phi-2 LLM.
567
+
568
+ <a target="_blank" href="https://lightning.ai/lightning-ai/studios/litgpt-chat">
569
+ <img src="https://pl-bolts-doc-images.s3.us-east-2.amazonaws.com/app-2/studio-badge.svg" alt="Open In Studio"/>
570
+ </a>
571
+
572
+ &nbsp;
573
+
574
+ ```bash
575
+ # 1) List all available models in litgpt
576
+ litgpt download list
577
+
578
+ # 2) Download a pretrained model
579
+ litgpt download microsoft/phi-2
580
+
581
+ # 3) Chat with the model
582
+ litgpt chat microsoft/phi-2
583
+
584
+ >> Prompt: What do Llamas eat?
585
+ ```
586
+
587
+ The download of certain models requires an additional access token. You can read more about this in the [download](tutorials/download_model_weights.md#specific-models-and-access-tokens) documentation.
588
+ For more information on the different inference options, refer to the [inference](tutorials/inference.md) tutorial.
589
+
590
+ ----
591
+ &nbsp;
592
+
548
593
  # State-of-the-art features
594
+
549
595
  ✅ &nbsp;State-of-the-art optimizations: Flash Attention v2, multi-GPU support via fully-sharded data parallelism, [optional CPU offloading](tutorials/oom.md#do-sharding-across-multiple-gpus), and [TPU and XLA support](extensions/xla).
550
596
 
551
597
  ✅ &nbsp;[Pretrain](tutorials/pretrain.md), [finetune](tutorials/finetune.md), and [deploy](tutorials/inference.md)
@@ -580,8 +626,9 @@ Browse all training recipes [here](config_hub).
580
626
  litgpt finetune \
581
627
  --config https://raw.githubusercontent.com/Lightning-AI/litgpt/main/config_hub/finetune/llama-2-7b/lora.yaml
582
628
  ```
583
-
584
- ### What is a config
629
+ <details>
630
+ <summary>✅ Use configs to customize training</summary>
631
+
585
632
  Configs let you customize training for all granular parameters like:
586
633
 
587
634
  ```yaml
@@ -596,9 +643,10 @@ precision: bf16-true
596
643
 
597
644
  ...
598
645
  ```
646
+ </details>
599
647
 
600
648
  <details>
601
- <summary>Example: LoRA finetuning config</summary>
649
+ <summary>✅ Example: LoRA finetuning config</summary>
602
650
 
603
651
  &nbsp;
604
652
 
@@ -728,82 +776,51 @@ seed: 1337
728
776
  ```
729
777
  </details>
730
778
 
731
- ### Override config params via CLI
732
- Override any parameter in the CLI:
779
+ <details>
780
+ <summary>✅ Override any parameter in the CLI:</summary>
733
781
 
734
782
  ```bash
735
783
  litgpt finetune \
736
784
  --config https://raw.githubusercontent.com/Lightning-AI/litgpt/main/config_hub/finetune/llama-2-7b/lora.yaml \
737
785
  --lora_r 4
738
786
  ```
787
+ </details>
739
788
 
740
789
  &nbsp;
741
790
 
742
791
  # Community
743
792
 
744
- ## Get involved!
745
-
746
- We appreciate your feedback and contributions. If you have feature requests, questions, or want to contribute code or config files, please don't hesitate to use the [GitHub Issue](https://github.com/Lightning-AI/litgpt/issues) tracker.
747
-
748
793
  We welcome all individual contributors, regardless of their level of experience or hardware. Your contributions are valuable, and we are excited to see what you can accomplish in this collaborative and supportive environment.
749
794
 
750
- &nbsp;
751
-
752
- > [!TIP]
753
- > Unsure about contributing? Check out our [How to Contribute to LitGPT](https://lightning.ai/pages/community/tutorial/how-to-contribute-to-litgpt/) guide.
754
-
755
- If you have general questions about building with LitGPT, please [join our Discord](https://discord.gg/VptPCZkGNa).
756
-
795
+ - [Request a feature](https://github.com/Lightning-AI/litgpt/issues)
796
+ - [Submit your first contribution](https://lightning.ai/pages/community/tutorial/how-to-contribute-to-litgpt/)
797
+ - [Join our Discord](https://discord.gg/VptPCZkGNa)
757
798
 
758
799
  &nbsp;
759
800
 
760
- ## Tutorials, how-to guides, and docs
761
-
762
-
763
- > [!NOTE]
764
- > We recommend starting with the **[Zero to LitGPT: Getting Started with Pretraining, Finetuning, and Using LLMs](tutorials/0_to_litgpt.md)** if you are looking to get started with using LitGPT.
765
-
766
- Tutorials and in-depth feature documentation can be found below:
801
+ # Tutorials
767
802
 
768
- - Finetuning, incl. LoRA, QLoRA, and Adapters ([tutorials/finetune.md](tutorials/finetune.md))
769
- - Pretraining ([tutorials/pretrain.md](tutorials/pretrain.md))
770
- - Model evaluation ([tutorials/evaluation.md](tutorials/evaluation.md))
771
- - Supported and custom datasets ([tutorials/prepare_dataset.md](tutorials/prepare_dataset.md))
772
- - Quantization ([tutorials/quantize.md](tutorials/quantize.md))
773
- - Tips for dealing with out-of-memory (OOM) errors ([tutorials/oom.md](tutorials/oom.md))
803
+ 🚀 [Get started](tutorials/0_to_litgpt.md)
804
+ ⚡️ [Finetuning, incl. LoRA, QLoRA, and Adapters](tutorials/finetune.md)
805
+ 🤖 [Pretraining](tutorials/pretrain.md)
806
+ 💬 [Model evaluation](tutorials/evaluation.md)
807
+ 📘 [Supported and custom datasets](tutorials/prepare_dataset.md)
808
+ 🧹 [Quantization](tutorials/quantize.md)
809
+ 🤯 [Tips for dealing with out-of-memory (OOM) errors](tutorials/oom.md)
810
+ 🧑🏽‍💻 [Using cloud TPUs](extensions/xla)
774
811
 
775
812
  &nbsp;
776
813
 
777
- ## XLA
778
-
779
- Lightning AI has partnered with Google to add first-class support for [Cloud TPUs](https://cloud.google.com/tpu) in [Lightning's frameworks](https://github.com/Lightning-AI/lightning) and LitGPT,
780
- helping democratize AI for millions of developers and researchers worldwide.
781
-
782
- Using TPUs with Lightning is as straightforward as changing one line of code.
783
-
784
- We provide scripts fully optimized for TPUs in the [XLA directory](extensions/xla).
785
814
 
815
+ ## Projects using LitGPT
786
816
 
817
+ Check out the projects below that use and build on LitGPT. If you have a project you'd like to add to this section, please don't hesitate to open a pull request.
787
818
 
788
819
  &nbsp;
789
820
 
790
- ## Acknowledgements
791
-
792
- This implementation extends on [Lit-LLaMA](https://github.com/lightning-AI/lit-llama) and [nanoGPT](https://github.com/karpathy/nanoGPT), and it's **powered by [Lightning Fabric](https://lightning.ai/docs/fabric/stable/) ⚡**.
793
-
794
- - [@karpathy](https://github.com/karpathy) for [nanoGPT](https://github.com/karpathy/nanoGPT)
795
- - [@EleutherAI](https://github.com/EleutherAI) for [GPT-NeoX](https://github.com/EleutherAI/gpt-neox) and the [Evaluation Harness](https://github.com/EleutherAI/lm-evaluation-harness)
796
- - [@TimDettmers](https://github.com/TimDettmers) for [bitsandbytes](https://github.com/TimDettmers/bitsandbytes)
797
- - [@Microsoft](https://github.com/microsoft) for [LoRA](https://github.com/microsoft/LoRA)
798
- - [@tridao](https://github.com/tridao) for [Flash Attention 2](https://github.com/Dao-AILab/flash-attention)
821
+ 📊 **SAMBA: Simple Hybrid State Space Models for Efficient Unlimited Context Language Modeling**
799
822
 
800
-
801
- &nbsp;
802
-
803
-
804
- ## Community showcase
805
-
806
- Check out the projects below that use and build on LitGPT. If you have a project you'd like to add to this section, please don't hesitate to open a pull request.
823
+ The [Samba](https://github.com/microsoft/Samba) project by researchers at Microsoft is built on top of the LitGPT code base and combines state space models with sliding window attention, which outperforms pure state space models.
807
824
 
808
825
  &nbsp;
809
826
 
@@ -831,6 +848,23 @@ The research paper ["Pre-training Small Base LMs with Fewer Tokens"](https://arx
831
848
 
832
849
  &nbsp;
833
850
 
851
+ ## Acknowledgements
852
+
853
+ This implementation extends on [Lit-LLaMA](https://github.com/lightning-AI/lit-llama) and [nanoGPT](https://github.com/karpathy/nanoGPT), and it's **powered by [Lightning Fabric](https://lightning.ai/docs/fabric/stable/) ⚡**.
854
+
855
+ - [@karpathy](https://github.com/karpathy) for [nanoGPT](https://github.com/karpathy/nanoGPT)
856
+ - [@EleutherAI](https://github.com/EleutherAI) for [GPT-NeoX](https://github.com/EleutherAI/gpt-neox) and the [Evaluation Harness](https://github.com/EleutherAI/lm-evaluation-harness)
857
+ - [@TimDettmers](https://github.com/TimDettmers) for [bitsandbytes](https://github.com/TimDettmers/bitsandbytes)
858
+ - [@Microsoft](https://github.com/microsoft) for [LoRA](https://github.com/microsoft/LoRA)
859
+ - [@tridao](https://github.com/tridao) for [Flash Attention 2](https://github.com/Dao-AILab/flash-attention)
860
+
861
+ &nbsp;
862
+
863
+ ## License
864
+
865
+ LitGPT is released under the [Apache 2.0](https://github.com/Lightning-AI/litgpt/blob/main/LICENSE) license.
866
+
867
+
834
868
  ## Citation
835
869
 
836
870
  If you use LitGPT in your research, please cite the following work:
@@ -845,7 +879,3 @@ If you use LitGPT in your research, please cite the following work:
845
879
  ```
846
880
 
847
881
  &nbsp;
848
-
849
- ## License
850
-
851
- LitGPT is released under the [Apache 2.0](https://github.com/Lightning-AI/litgpt/blob/main/LICENSE) license.