Text Generation
Transformers
TensorBoard
Safetensors
Thai
English
gemma4
image-text-to-text
legal
thai
continued-pretraining
cpt
law
gemma
causal-lm
Instructions to use Phonsiri/Thai-Legal-Gemma-4B-CPT with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use Phonsiri/Thai-Legal-Gemma-4B-CPT with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="Phonsiri/Thai-Legal-Gemma-4B-CPT")# Load model directly from transformers import AutoProcessor, AutoModelForMultimodalLM processor = AutoProcessor.from_pretrained("Phonsiri/Thai-Legal-Gemma-4B-CPT") model = AutoModelForMultimodalLM.from_pretrained("Phonsiri/Thai-Legal-Gemma-4B-CPT", device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use Phonsiri/Thai-Legal-Gemma-4B-CPT with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "Phonsiri/Thai-Legal-Gemma-4B-CPT" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "Phonsiri/Thai-Legal-Gemma-4B-CPT", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/Phonsiri/Thai-Legal-Gemma-4B-CPT
- SGLang
How to use Phonsiri/Thai-Legal-Gemma-4B-CPT with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "Phonsiri/Thai-Legal-Gemma-4B-CPT" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "Phonsiri/Thai-Legal-Gemma-4B-CPT", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "Phonsiri/Thai-Legal-Gemma-4B-CPT" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "Phonsiri/Thai-Legal-Gemma-4B-CPT", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use Phonsiri/Thai-Legal-Gemma-4B-CPT with Docker Model Runner:
docker model run hf.co/Phonsiri/Thai-Legal-Gemma-4B-CPT
| { | |
| "best_global_step": null, | |
| "best_metric": null, | |
| "best_model_checkpoint": null, | |
| "epoch": 0.5242678681138644, | |
| "eval_steps": 1, | |
| "global_step": 50, | |
| "is_hyper_param_search": false, | |
| "is_local_process_zero": true, | |
| "is_world_process_zero": true, | |
| "log_history": [ | |
| { | |
| "epoch": 0.010485357362277289, | |
| "grad_norm": 498.0, | |
| "learning_rate": 0.0, | |
| "loss": 1.6033425331115723, | |
| "step": 1 | |
| }, | |
| { | |
| "epoch": 0.020970714724554577, | |
| "grad_norm": 139.0, | |
| "learning_rate": 4e-08, | |
| "loss": 1.5843058824539185, | |
| "step": 2 | |
| }, | |
| { | |
| "epoch": 0.03145607208683186, | |
| "grad_norm": 158.0, | |
| "learning_rate": 8e-08, | |
| "loss": 1.624650239944458, | |
| "step": 3 | |
| }, | |
| { | |
| "epoch": 0.041941429449109155, | |
| "grad_norm": 201.0, | |
| "learning_rate": 1.2000000000000002e-07, | |
| "loss": 1.5930713415145874, | |
| "step": 4 | |
| }, | |
| { | |
| "epoch": 0.05242678681138644, | |
| "grad_norm": 1392.0, | |
| "learning_rate": 1.6e-07, | |
| "loss": 1.6284583806991577, | |
| "step": 5 | |
| }, | |
| { | |
| "epoch": 0.06291214417366373, | |
| "grad_norm": 644.0, | |
| "learning_rate": 2.0000000000000002e-07, | |
| "loss": 1.5755040645599365, | |
| "step": 6 | |
| }, | |
| { | |
| "epoch": 0.07339750153594102, | |
| "grad_norm": 358.0, | |
| "learning_rate": 2.4000000000000003e-07, | |
| "loss": 1.5862637758255005, | |
| "step": 7 | |
| }, | |
| { | |
| "epoch": 0.08388285889821831, | |
| "grad_norm": 1012.0, | |
| "learning_rate": 2.8e-07, | |
| "loss": 1.6306817531585693, | |
| "step": 8 | |
| }, | |
| { | |
| "epoch": 0.0943682162604956, | |
| "grad_norm": 187.0, | |
| "learning_rate": 3.2e-07, | |
| "loss": 1.5844253301620483, | |
| "step": 9 | |
| }, | |
| { | |
| "epoch": 0.10485357362277288, | |
| "grad_norm": 342.0, | |
| "learning_rate": 3.6e-07, | |
| "loss": 1.5895334482192993, | |
| "step": 10 | |
| }, | |
| { | |
| "epoch": 0.11533893098505017, | |
| "grad_norm": 816.0, | |
| "learning_rate": 4.0000000000000003e-07, | |
| "loss": 1.5861637592315674, | |
| "step": 11 | |
| }, | |
| { | |
| "epoch": 0.12582428834732745, | |
| "grad_norm": 260.0, | |
| "learning_rate": 4.4e-07, | |
| "loss": 1.57806396484375, | |
| "step": 12 | |
| }, | |
| { | |
| "epoch": 0.13630964570960474, | |
| "grad_norm": 326.0, | |
| "learning_rate": 4.800000000000001e-07, | |
| "loss": 1.5836868286132812, | |
| "step": 13 | |
| }, | |
| { | |
| "epoch": 0.14679500307188204, | |
| "grad_norm": 668.0, | |
| "learning_rate": 5.2e-07, | |
| "loss": 1.5597259998321533, | |
| "step": 14 | |
| }, | |
| { | |
| "epoch": 0.15728036043415933, | |
| "grad_norm": 256.0, | |
| "learning_rate": 5.6e-07, | |
| "loss": 1.5852601528167725, | |
| "step": 15 | |
| }, | |
| { | |
| "epoch": 0.16776571779643662, | |
| "grad_norm": 205.0, | |
| "learning_rate": 6.000000000000001e-07, | |
| "loss": 1.5899027585983276, | |
| "step": 16 | |
| }, | |
| { | |
| "epoch": 0.1782510751587139, | |
| "grad_norm": 188.0, | |
| "learning_rate": 6.4e-07, | |
| "loss": 1.5692049264907837, | |
| "step": 17 | |
| }, | |
| { | |
| "epoch": 0.1887364325209912, | |
| "grad_norm": 426.0, | |
| "learning_rate": 6.800000000000001e-07, | |
| "loss": 1.55263090133667, | |
| "step": 18 | |
| }, | |
| { | |
| "epoch": 0.1992217898832685, | |
| "grad_norm": 245.0, | |
| "learning_rate": 7.2e-07, | |
| "loss": 1.5602704286575317, | |
| "step": 19 | |
| }, | |
| { | |
| "epoch": 0.20970714724554576, | |
| "grad_norm": 158.0, | |
| "learning_rate": 7.6e-07, | |
| "loss": 1.5857173204421997, | |
| "step": 20 | |
| }, | |
| { | |
| "epoch": 0.22019250460782305, | |
| "grad_norm": 90.0, | |
| "learning_rate": 8.000000000000001e-07, | |
| "loss": 1.5650298595428467, | |
| "step": 21 | |
| }, | |
| { | |
| "epoch": 0.23067786197010035, | |
| "grad_norm": 148.0, | |
| "learning_rate": 8.400000000000001e-07, | |
| "loss": 1.548302173614502, | |
| "step": 22 | |
| }, | |
| { | |
| "epoch": 0.24116321933237764, | |
| "grad_norm": 187.0, | |
| "learning_rate": 8.8e-07, | |
| "loss": 1.5342053174972534, | |
| "step": 23 | |
| }, | |
| { | |
| "epoch": 0.2516485766946549, | |
| "grad_norm": 282.0, | |
| "learning_rate": 9.200000000000001e-07, | |
| "loss": 1.5395140647888184, | |
| "step": 24 | |
| }, | |
| { | |
| "epoch": 0.2621339340569322, | |
| "grad_norm": 212.0, | |
| "learning_rate": 9.600000000000001e-07, | |
| "loss": 1.5411065816879272, | |
| "step": 25 | |
| }, | |
| { | |
| "epoch": 0.2726192914192095, | |
| "grad_norm": 1640.0, | |
| "learning_rate": 1.0000000000000002e-06, | |
| "loss": 1.520958423614502, | |
| "step": 26 | |
| }, | |
| { | |
| "epoch": 0.2831046487814868, | |
| "grad_norm": 161.0, | |
| "learning_rate": 1.04e-06, | |
| "loss": 1.516421914100647, | |
| "step": 27 | |
| }, | |
| { | |
| "epoch": 0.29359000614376407, | |
| "grad_norm": 175.0, | |
| "learning_rate": 1.08e-06, | |
| "loss": 1.492469310760498, | |
| "step": 28 | |
| }, | |
| { | |
| "epoch": 0.30407536350604136, | |
| "grad_norm": 115.0, | |
| "learning_rate": 1.12e-06, | |
| "loss": 1.5238401889801025, | |
| "step": 29 | |
| }, | |
| { | |
| "epoch": 0.31456072086831866, | |
| "grad_norm": 96.5, | |
| "learning_rate": 1.1600000000000001e-06, | |
| "loss": 1.4782272577285767, | |
| "step": 30 | |
| }, | |
| { | |
| "epoch": 0.32504607823059595, | |
| "grad_norm": 197.0, | |
| "learning_rate": 1.2000000000000002e-06, | |
| "loss": 1.4808753728866577, | |
| "step": 31 | |
| }, | |
| { | |
| "epoch": 0.33553143559287324, | |
| "grad_norm": 125.0, | |
| "learning_rate": 1.2400000000000002e-06, | |
| "loss": 1.4171360731124878, | |
| "step": 32 | |
| }, | |
| { | |
| "epoch": 0.34601679295515053, | |
| "grad_norm": 580.0, | |
| "learning_rate": 1.28e-06, | |
| "loss": 1.4474064111709595, | |
| "step": 33 | |
| }, | |
| { | |
| "epoch": 0.3565021503174278, | |
| "grad_norm": 83.5, | |
| "learning_rate": 1.32e-06, | |
| "loss": 1.4120572805404663, | |
| "step": 34 | |
| }, | |
| { | |
| "epoch": 0.3669875076797051, | |
| "grad_norm": 201.0, | |
| "learning_rate": 1.3600000000000001e-06, | |
| "loss": 1.4311250448226929, | |
| "step": 35 | |
| }, | |
| { | |
| "epoch": 0.3774728650419824, | |
| "grad_norm": 121.0, | |
| "learning_rate": 1.4000000000000001e-06, | |
| "loss": 1.4023066759109497, | |
| "step": 36 | |
| }, | |
| { | |
| "epoch": 0.3879582224042597, | |
| "grad_norm": 51.25, | |
| "learning_rate": 1.44e-06, | |
| "loss": 1.3962011337280273, | |
| "step": 37 | |
| }, | |
| { | |
| "epoch": 0.398443579766537, | |
| "grad_norm": 67.0, | |
| "learning_rate": 1.48e-06, | |
| "loss": 1.409425139427185, | |
| "step": 38 | |
| }, | |
| { | |
| "epoch": 0.40892893712881423, | |
| "grad_norm": 60.5, | |
| "learning_rate": 1.52e-06, | |
| "loss": 1.3721140623092651, | |
| "step": 39 | |
| }, | |
| { | |
| "epoch": 0.4194142944910915, | |
| "grad_norm": 58.5, | |
| "learning_rate": 1.56e-06, | |
| "loss": 1.375535011291504, | |
| "step": 40 | |
| }, | |
| { | |
| "epoch": 0.4298996518533688, | |
| "grad_norm": 144.0, | |
| "learning_rate": 1.6000000000000001e-06, | |
| "loss": 1.3638286590576172, | |
| "step": 41 | |
| }, | |
| { | |
| "epoch": 0.4403850092156461, | |
| "grad_norm": 348.0, | |
| "learning_rate": 1.6400000000000002e-06, | |
| "loss": 1.3767451047897339, | |
| "step": 42 | |
| }, | |
| { | |
| "epoch": 0.4508703665779234, | |
| "grad_norm": 102.0, | |
| "learning_rate": 1.6800000000000002e-06, | |
| "loss": 1.3871445655822754, | |
| "step": 43 | |
| }, | |
| { | |
| "epoch": 0.4613557239402007, | |
| "grad_norm": 83.5, | |
| "learning_rate": 1.72e-06, | |
| "loss": 1.3462551832199097, | |
| "step": 44 | |
| }, | |
| { | |
| "epoch": 0.471841081302478, | |
| "grad_norm": 75.0, | |
| "learning_rate": 1.76e-06, | |
| "loss": 1.3668186664581299, | |
| "step": 45 | |
| }, | |
| { | |
| "epoch": 0.4823264386647553, | |
| "grad_norm": 51.75, | |
| "learning_rate": 1.8000000000000001e-06, | |
| "loss": 1.3438992500305176, | |
| "step": 46 | |
| }, | |
| { | |
| "epoch": 0.49281179602703257, | |
| "grad_norm": 64.0, | |
| "learning_rate": 1.8400000000000002e-06, | |
| "loss": 1.3390253782272339, | |
| "step": 47 | |
| }, | |
| { | |
| "epoch": 0.5032971533893098, | |
| "grad_norm": 45.5, | |
| "learning_rate": 1.8800000000000002e-06, | |
| "loss": 1.365052580833435, | |
| "step": 48 | |
| }, | |
| { | |
| "epoch": 0.5137825107515871, | |
| "grad_norm": 66.0, | |
| "learning_rate": 1.9200000000000003e-06, | |
| "loss": 1.3313298225402832, | |
| "step": 49 | |
| }, | |
| { | |
| "epoch": 0.5242678681138644, | |
| "grad_norm": 50.25, | |
| "learning_rate": 1.9600000000000003e-06, | |
| "loss": 1.335034966468811, | |
| "step": 50 | |
| } | |
| ], | |
| "logging_steps": 1, | |
| "max_steps": 96, | |
| "num_input_tokens_seen": 0, | |
| "num_train_epochs": 1, | |
| "save_steps": 5, | |
| "stateful_callbacks": { | |
| "TrainerControl": { | |
| "args": { | |
| "should_epoch_stop": false, | |
| "should_evaluate": false, | |
| "should_log": false, | |
| "should_save": true, | |
| "should_training_stop": false | |
| }, | |
| "attributes": {} | |
| } | |
| }, | |
| "total_flos": 2.8006038292660224e+18, | |
| "train_batch_size": 1, | |
| "trial_name": null, | |
| "trial_params": null | |
| } | |