@synsci/cli-darwin-x64 1.1.70 → 1.1.72
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.
- package/bin/skills/citation-management/SKILL.md +1109 -0
- package/bin/skills/citation-management/assets/bibtex_template.bib +264 -0
- package/bin/skills/citation-management/assets/citation_checklist.md +386 -0
- package/bin/skills/citation-management/references/bibtex_formatting.md +908 -0
- package/bin/skills/citation-management/references/citation_validation.md +794 -0
- package/bin/skills/citation-management/references/google_scholar_search.md +725 -0
- package/bin/skills/citation-management/references/metadata_extraction.md +870 -0
- package/bin/skills/citation-management/references/pubmed_search.md +839 -0
- package/bin/skills/citation-management/scripts/doi_to_bibtex.py +182 -0
- package/bin/skills/citation-management/scripts/extract_metadata.py +570 -0
- package/bin/skills/citation-management/scripts/format_bibtex.py +349 -0
- package/bin/skills/citation-management/scripts/search_google_scholar.py +251 -0
- package/bin/skills/citation-management/scripts/search_pubmed.py +348 -0
- package/bin/skills/citation-management/scripts/validate_citations.py +494 -0
- package/bin/skills/clinical-decision-support/README.md +129 -0
- package/bin/skills/clinical-decision-support/SKILL.md +506 -0
- package/bin/skills/clinical-decision-support/assets/biomarker_report_template.tex +380 -0
- package/bin/skills/clinical-decision-support/assets/clinical_pathway_template.tex +222 -0
- package/bin/skills/clinical-decision-support/assets/cohort_analysis_template.tex +359 -0
- package/bin/skills/clinical-decision-support/assets/color_schemes.tex +149 -0
- package/bin/skills/clinical-decision-support/assets/example_gbm_cohort.md +208 -0
- package/bin/skills/clinical-decision-support/assets/recommendation_strength_guide.md +328 -0
- package/bin/skills/clinical-decision-support/assets/treatment_recommendation_template.tex +529 -0
- package/bin/skills/clinical-decision-support/references/biomarker_classification.md +719 -0
- package/bin/skills/clinical-decision-support/references/clinical_decision_algorithms.md +604 -0
- package/bin/skills/clinical-decision-support/references/evidence_synthesis.md +840 -0
- package/bin/skills/clinical-decision-support/references/outcome_analysis.md +640 -0
- package/bin/skills/clinical-decision-support/references/patient_cohort_analysis.md +427 -0
- package/bin/skills/clinical-decision-support/references/treatment_recommendations.md +521 -0
- package/bin/skills/clinical-decision-support/scripts/biomarker_classifier.py +383 -0
- package/bin/skills/clinical-decision-support/scripts/build_decision_tree.py +417 -0
- package/bin/skills/clinical-decision-support/scripts/create_cohort_tables.py +509 -0
- package/bin/skills/clinical-decision-support/scripts/generate_survival_analysis.py +441 -0
- package/bin/skills/clinical-decision-support/scripts/validate_cds_document.py +326 -0
- package/bin/skills/clinical-reports/IMPLEMENTATION_SUMMARY.md +641 -0
- package/bin/skills/clinical-reports/README.md +236 -0
- package/bin/skills/clinical-reports/SKILL.md +1127 -0
- package/bin/skills/clinical-reports/assets/case_report_template.md +352 -0
- package/bin/skills/clinical-reports/assets/clinical_trial_csr_template.md +353 -0
- package/bin/skills/clinical-reports/assets/clinical_trial_sae_template.md +359 -0
- package/bin/skills/clinical-reports/assets/consult_note_template.md +305 -0
- package/bin/skills/clinical-reports/assets/discharge_summary_template.md +453 -0
- package/bin/skills/clinical-reports/assets/hipaa_compliance_checklist.md +395 -0
- package/bin/skills/clinical-reports/assets/history_physical_template.md +305 -0
- package/bin/skills/clinical-reports/assets/lab_report_template.md +309 -0
- package/bin/skills/clinical-reports/assets/pathology_report_template.md +249 -0
- package/bin/skills/clinical-reports/assets/quality_checklist.md +338 -0
- package/bin/skills/clinical-reports/assets/radiology_report_template.md +318 -0
- package/bin/skills/clinical-reports/assets/soap_note_template.md +253 -0
- package/bin/skills/clinical-reports/references/case_report_guidelines.md +570 -0
- package/bin/skills/clinical-reports/references/clinical_trial_reporting.md +693 -0
- package/bin/skills/clinical-reports/references/data_presentation.md +530 -0
- package/bin/skills/clinical-reports/references/diagnostic_reports_standards.md +629 -0
- package/bin/skills/clinical-reports/references/medical_terminology.md +588 -0
- package/bin/skills/clinical-reports/references/patient_documentation.md +744 -0
- package/bin/skills/clinical-reports/references/peer_review_standards.md +585 -0
- package/bin/skills/clinical-reports/references/regulatory_compliance.md +577 -0
- package/bin/skills/clinical-reports/scripts/check_deidentification.py +332 -0
- package/bin/skills/clinical-reports/scripts/compliance_checker.py +78 -0
- package/bin/skills/clinical-reports/scripts/extract_clinical_data.py +97 -0
- package/bin/skills/clinical-reports/scripts/format_adverse_events.py +97 -0
- package/bin/skills/clinical-reports/scripts/generate_report_template.py +149 -0
- package/bin/skills/clinical-reports/scripts/terminology_validator.py +126 -0
- package/bin/skills/clinical-reports/scripts/validate_case_report.py +323 -0
- package/bin/skills/clinical-reports/scripts/validate_trial_report.py +88 -0
- package/bin/skills/fireworks-ai/SKILL.md +665 -0
- package/bin/skills/generate-image/SKILL.md +178 -0
- package/bin/skills/generate-image/scripts/generate_image.py +254 -0
- package/bin/skills/groq/SKILL.md +347 -0
- package/bin/skills/hypothesis-generation/SKILL.md +293 -0
- package/bin/skills/hypothesis-generation/assets/FORMATTING_GUIDE.md +672 -0
- package/bin/skills/hypothesis-generation/assets/hypothesis_generation.sty +307 -0
- package/bin/skills/hypothesis-generation/assets/hypothesis_report_template.tex +572 -0
- package/bin/skills/hypothesis-generation/references/experimental_design_patterns.md +329 -0
- package/bin/skills/hypothesis-generation/references/hypothesis_quality_criteria.md +198 -0
- package/bin/skills/hypothesis-generation/references/literature_search_strategies.md +622 -0
- package/bin/skills/latex-posters/README.md +417 -0
- package/bin/skills/latex-posters/SKILL.md +1602 -0
- package/bin/skills/latex-posters/assets/baposter_template.tex +257 -0
- package/bin/skills/latex-posters/assets/beamerposter_template.tex +244 -0
- package/bin/skills/latex-posters/assets/poster_quality_checklist.md +358 -0
- package/bin/skills/latex-posters/assets/tikzposter_template.tex +251 -0
- package/bin/skills/latex-posters/references/latex_poster_packages.md +745 -0
- package/bin/skills/latex-posters/references/poster_content_guide.md +748 -0
- package/bin/skills/latex-posters/references/poster_design_principles.md +806 -0
- package/bin/skills/latex-posters/references/poster_layout_design.md +900 -0
- package/bin/skills/latex-posters/scripts/review_poster.sh +214 -0
- package/bin/skills/literature-review/SKILL.md +641 -0
- package/bin/skills/literature-review/assets/review_template.md +412 -0
- package/bin/skills/literature-review/references/citation_styles.md +166 -0
- package/bin/skills/literature-review/references/database_strategies.md +455 -0
- package/bin/skills/literature-review/scripts/generate_pdf.py +184 -0
- package/bin/skills/literature-review/scripts/search_databases.py +310 -0
- package/bin/skills/literature-review/scripts/verify_citations.py +218 -0
- package/bin/skills/market-research-reports/SKILL.md +904 -0
- package/bin/skills/market-research-reports/assets/FORMATTING_GUIDE.md +428 -0
- package/bin/skills/market-research-reports/assets/market_report_template.tex +1380 -0
- package/bin/skills/market-research-reports/assets/market_research.sty +564 -0
- package/bin/skills/market-research-reports/references/data_analysis_patterns.md +548 -0
- package/bin/skills/market-research-reports/references/report_structure_guide.md +999 -0
- package/bin/skills/market-research-reports/references/visual_generation_guide.md +1077 -0
- package/bin/skills/market-research-reports/scripts/generate_market_visuals.py +472 -0
- package/bin/skills/markitdown/INSTALLATION_GUIDE.md +318 -0
- package/bin/skills/markitdown/LICENSE.txt +22 -0
- package/bin/skills/markitdown/OPENROUTER_INTEGRATION.md +359 -0
- package/bin/skills/markitdown/QUICK_REFERENCE.md +309 -0
- package/bin/skills/markitdown/README.md +184 -0
- package/bin/skills/markitdown/SKILL.md +486 -0
- package/bin/skills/markitdown/SKILL_SUMMARY.md +307 -0
- package/bin/skills/markitdown/assets/example_usage.md +463 -0
- package/bin/skills/markitdown/references/api_reference.md +399 -0
- package/bin/skills/markitdown/references/file_formats.md +542 -0
- package/bin/skills/markitdown/scripts/batch_convert.py +195 -0
- package/bin/skills/markitdown/scripts/convert_literature.py +262 -0
- package/bin/skills/markitdown/scripts/convert_with_ai.py +224 -0
- package/bin/skills/ml-paper-writing/SKILL.md +937 -0
- package/bin/skills/ml-paper-writing/references/checklists.md +361 -0
- package/bin/skills/ml-paper-writing/references/citation-workflow.md +562 -0
- package/bin/skills/ml-paper-writing/references/reviewer-guidelines.md +367 -0
- package/bin/skills/ml-paper-writing/references/sources.md +159 -0
- package/bin/skills/ml-paper-writing/references/writing-guide.md +476 -0
- package/bin/skills/ml-paper-writing/templates/README.md +251 -0
- package/bin/skills/ml-paper-writing/templates/aaai2026/README.md +534 -0
- package/bin/skills/ml-paper-writing/templates/aaai2026/aaai2026-unified-supp.tex +144 -0
- package/bin/skills/ml-paper-writing/templates/aaai2026/aaai2026-unified-template.tex +952 -0
- package/bin/skills/ml-paper-writing/templates/aaai2026/aaai2026.bib +111 -0
- package/bin/skills/ml-paper-writing/templates/aaai2026/aaai2026.bst +1493 -0
- package/bin/skills/ml-paper-writing/templates/aaai2026/aaai2026.sty +315 -0
- package/bin/skills/ml-paper-writing/templates/acl/README.md +50 -0
- package/bin/skills/ml-paper-writing/templates/acl/acl.sty +312 -0
- package/bin/skills/ml-paper-writing/templates/acl/acl_latex.tex +377 -0
- package/bin/skills/ml-paper-writing/templates/acl/acl_lualatex.tex +101 -0
- package/bin/skills/ml-paper-writing/templates/acl/acl_natbib.bst +1940 -0
- package/bin/skills/ml-paper-writing/templates/acl/anthology.bib.txt +26 -0
- package/bin/skills/ml-paper-writing/templates/acl/custom.bib +70 -0
- package/bin/skills/ml-paper-writing/templates/acl/formatting.md +326 -0
- package/bin/skills/ml-paper-writing/templates/colm2025/README.md +3 -0
- package/bin/skills/ml-paper-writing/templates/colm2025/colm2025_conference.bib +11 -0
- package/bin/skills/ml-paper-writing/templates/colm2025/colm2025_conference.bst +1440 -0
- package/bin/skills/ml-paper-writing/templates/colm2025/colm2025_conference.pdf +0 -0
- package/bin/skills/ml-paper-writing/templates/colm2025/colm2025_conference.sty +218 -0
- package/bin/skills/ml-paper-writing/templates/colm2025/colm2025_conference.tex +305 -0
- package/bin/skills/ml-paper-writing/templates/colm2025/fancyhdr.sty +485 -0
- package/bin/skills/ml-paper-writing/templates/colm2025/math_commands.tex +508 -0
- package/bin/skills/ml-paper-writing/templates/colm2025/natbib.sty +1246 -0
- package/bin/skills/ml-paper-writing/templates/iclr2026/fancyhdr.sty +485 -0
- package/bin/skills/ml-paper-writing/templates/iclr2026/iclr2026_conference.bib +24 -0
- package/bin/skills/ml-paper-writing/templates/iclr2026/iclr2026_conference.bst +1440 -0
- package/bin/skills/ml-paper-writing/templates/iclr2026/iclr2026_conference.pdf +0 -0
- package/bin/skills/ml-paper-writing/templates/iclr2026/iclr2026_conference.sty +246 -0
- package/bin/skills/ml-paper-writing/templates/iclr2026/iclr2026_conference.tex +414 -0
- package/bin/skills/ml-paper-writing/templates/iclr2026/math_commands.tex +508 -0
- package/bin/skills/ml-paper-writing/templates/iclr2026/natbib.sty +1246 -0
- package/bin/skills/ml-paper-writing/templates/icml2026/algorithm.sty +79 -0
- package/bin/skills/ml-paper-writing/templates/icml2026/algorithmic.sty +201 -0
- package/bin/skills/ml-paper-writing/templates/icml2026/example_paper.bib +75 -0
- package/bin/skills/ml-paper-writing/templates/icml2026/example_paper.pdf +0 -0
- package/bin/skills/ml-paper-writing/templates/icml2026/example_paper.tex +662 -0
- package/bin/skills/ml-paper-writing/templates/icml2026/fancyhdr.sty +864 -0
- package/bin/skills/ml-paper-writing/templates/icml2026/icml2026.bst +1443 -0
- package/bin/skills/ml-paper-writing/templates/icml2026/icml2026.sty +767 -0
- package/bin/skills/ml-paper-writing/templates/icml2026/icml_numpapers.pdf +0 -0
- package/bin/skills/ml-paper-writing/templates/neurips2025/Makefile +36 -0
- package/bin/skills/ml-paper-writing/templates/neurips2025/extra_pkgs.tex +53 -0
- package/bin/skills/ml-paper-writing/templates/neurips2025/main.tex +38 -0
- package/bin/skills/ml-paper-writing/templates/neurips2025/neurips.sty +382 -0
- package/bin/skills/paper-2-web/SKILL.md +491 -0
- package/bin/skills/paper-2-web/references/installation.md +141 -0
- package/bin/skills/paper-2-web/references/paper2poster.md +346 -0
- package/bin/skills/paper-2-web/references/paper2video.md +305 -0
- package/bin/skills/paper-2-web/references/paper2web.md +187 -0
- package/bin/skills/paper-2-web/references/usage_examples.md +436 -0
- package/bin/skills/peer-review/SKILL.md +702 -0
- package/bin/skills/peer-review/references/calibration_guidelines.md +196 -0
- package/bin/skills/peer-review/references/common_issues.md +552 -0
- package/bin/skills/peer-review/references/paper_mechanics.md +269 -0
- package/bin/skills/peer-review/references/reporting_standards.md +290 -0
- package/bin/skills/peer-review/references/scoring_rubric.md +239 -0
- package/bin/skills/pptx-posters/SKILL.md +410 -0
- package/bin/skills/pptx-posters/assets/poster_html_template.html +257 -0
- package/bin/skills/pptx-posters/assets/poster_quality_checklist.md +358 -0
- package/bin/skills/pptx-posters/references/poster_content_guide.md +748 -0
- package/bin/skills/pptx-posters/references/poster_design_principles.md +806 -0
- package/bin/skills/pptx-posters/references/poster_layout_design.md +900 -0
- package/bin/skills/research-grants/README.md +285 -0
- package/bin/skills/research-grants/SKILL.md +938 -0
- package/bin/skills/research-grants/assets/budget_justification_template.md +453 -0
- package/bin/skills/research-grants/assets/nih_specific_aims_template.md +166 -0
- package/bin/skills/research-grants/assets/nsf_project_summary_template.md +92 -0
- package/bin/skills/research-grants/references/broader_impacts.md +392 -0
- package/bin/skills/research-grants/references/darpa_guidelines.md +636 -0
- package/bin/skills/research-grants/references/doe_guidelines.md +586 -0
- package/bin/skills/research-grants/references/nih_guidelines.md +851 -0
- package/bin/skills/research-grants/references/nsf_guidelines.md +570 -0
- package/bin/skills/research-grants/references/specific_aims_guide.md +458 -0
- package/bin/skills/research-lookup/README.md +156 -0
- package/bin/skills/research-lookup/SKILL.md +606 -0
- package/bin/skills/research-lookup/examples.py +174 -0
- package/bin/skills/research-lookup/lookup.py +187 -0
- package/bin/skills/research-lookup/research_lookup.py +483 -0
- package/bin/skills/research-lookup/scripts/research_lookup.py +483 -0
- package/bin/skills/scholar-evaluation/SKILL.md +289 -0
- package/bin/skills/scholar-evaluation/references/evaluation_framework.md +663 -0
- package/bin/skills/scholar-evaluation/scripts/calculate_scores.py +366 -0
- package/bin/skills/scientific-critical-thinking/SKILL.md +566 -0
- package/bin/skills/scientific-critical-thinking/references/common_biases.md +364 -0
- package/bin/skills/scientific-critical-thinking/references/evidence_hierarchy.md +484 -0
- package/bin/skills/scientific-critical-thinking/references/experimental_design.md +496 -0
- package/bin/skills/scientific-critical-thinking/references/logical_fallacies.md +478 -0
- package/bin/skills/scientific-critical-thinking/references/scientific_method.md +169 -0
- package/bin/skills/scientific-critical-thinking/references/statistical_pitfalls.md +506 -0
- package/bin/skills/scientific-schematics/QUICK_REFERENCE.md +207 -0
- package/bin/skills/scientific-schematics/README.md +327 -0
- package/bin/skills/scientific-schematics/SKILL.md +615 -0
- package/bin/skills/scientific-schematics/example_usage.sh +89 -0
- package/bin/skills/scientific-schematics/references/best_practices.md +559 -0
- package/bin/skills/scientific-schematics/scripts/generate_schematic.py +135 -0
- package/bin/skills/scientific-schematics/scripts/generate_schematic_ai.py +807 -0
- package/bin/skills/scientific-schematics/test_ai_generation.py +243 -0
- package/bin/skills/scientific-slides/SKILL.md +942 -0
- package/bin/skills/scientific-slides/assets/timing_guidelines.md +597 -0
- package/bin/skills/scientific-slides/references/data_visualization_slides.md +708 -0
- package/bin/skills/scientific-slides/references/presentation_structure.md +642 -0
- package/bin/skills/scientific-slides/references/slide_design_principles.md +849 -0
- package/bin/skills/scientific-slides/references/talk_types_guide.md +687 -0
- package/bin/skills/scientific-slides/references/visual_review_workflow.md +775 -0
- package/bin/skills/scientific-slides/scripts/generate_slide_image.py +143 -0
- package/bin/skills/scientific-slides/scripts/generate_slide_image_ai.py +748 -0
- package/bin/skills/scientific-slides/scripts/pdf_to_images.py +201 -0
- package/bin/skills/scientific-slides/scripts/slides_to_pdf.py +220 -0
- package/bin/skills/scientific-slides/scripts/validate_presentation.py +367 -0
- package/bin/skills/scientific-writing/SKILL.md +714 -0
- package/bin/skills/scientific-writing/assets/REPORT_FORMATTING_GUIDE.md +574 -0
- package/bin/skills/scientific-writing/assets/scientific_report.sty +606 -0
- package/bin/skills/scientific-writing/assets/scientific_report_template.tex +449 -0
- package/bin/skills/scientific-writing/references/citation_styles.md +720 -0
- package/bin/skills/scientific-writing/references/figures_tables.md +806 -0
- package/bin/skills/scientific-writing/references/imrad_structure.md +686 -0
- package/bin/skills/scientific-writing/references/professional_report_formatting.md +664 -0
- package/bin/skills/scientific-writing/references/reporting_guidelines.md +748 -0
- package/bin/skills/scientific-writing/references/writing_principles.md +824 -0
- package/bin/skills/tinker/SKILL.md +2 -3
- package/bin/skills/together-ai/SKILL.md +722 -0
- package/bin/skills/treatment-plans/README.md +488 -0
- package/bin/skills/treatment-plans/SKILL.md +1579 -0
- package/bin/skills/treatment-plans/assets/STYLING_QUICK_REFERENCE.md +185 -0
- package/bin/skills/treatment-plans/assets/chronic_disease_management_plan.tex +665 -0
- package/bin/skills/treatment-plans/assets/general_medical_treatment_plan.tex +547 -0
- package/bin/skills/treatment-plans/assets/medical_treatment_plan.sty +222 -0
- package/bin/skills/treatment-plans/assets/mental_health_treatment_plan.tex +774 -0
- package/bin/skills/treatment-plans/assets/one_page_treatment_plan.tex +193 -0
- package/bin/skills/treatment-plans/assets/pain_management_plan.tex +799 -0
- package/bin/skills/treatment-plans/assets/perioperative_care_plan.tex +753 -0
- package/bin/skills/treatment-plans/assets/quality_checklist.md +471 -0
- package/bin/skills/treatment-plans/assets/rehabilitation_treatment_plan.tex +756 -0
- package/bin/skills/treatment-plans/references/goal_setting_frameworks.md +411 -0
- package/bin/skills/treatment-plans/references/intervention_guidelines.md +507 -0
- package/bin/skills/treatment-plans/references/regulatory_compliance.md +476 -0
- package/bin/skills/treatment-plans/references/specialty_specific_guidelines.md +655 -0
- package/bin/skills/treatment-plans/references/treatment_plan_standards.md +485 -0
- package/bin/skills/treatment-plans/scripts/check_completeness.py +322 -0
- package/bin/skills/treatment-plans/scripts/generate_template.py +233 -0
- package/bin/skills/treatment-plans/scripts/timeline_generator.py +385 -0
- package/bin/skills/treatment-plans/scripts/validate_treatment_plan.py +369 -0
- package/bin/skills/unsloth/SKILL.md +565 -47
- package/bin/skills/unsloth/docs/advanced-rl.md +222 -0
- package/bin/skills/unsloth/docs/chat-templates.md +141 -0
- package/bin/skills/unsloth/docs/datasets.md +489 -0
- package/bin/skills/unsloth/docs/docker-extended.md +99 -0
- package/bin/skills/unsloth/docs/dynamic-ggufs-2.0.md +116 -0
- package/bin/skills/unsloth/docs/dynamic-ggufs-aider.md +118 -0
- package/bin/skills/unsloth/docs/faq.md +91 -0
- package/bin/skills/unsloth/docs/fp16-vs-bf16.md +61 -0
- package/bin/skills/unsloth/docs/fp8-rl.md +224 -0
- package/bin/skills/unsloth/docs/glm-4.7-flash.md +997 -0
- package/bin/skills/unsloth/docs/inference-deployment-overview.md +17 -0
- package/bin/skills/unsloth/docs/inference.md +27 -0
- package/bin/skills/unsloth/docs/installation-docker.md +155 -0
- package/bin/skills/unsloth/docs/installation-pip.md +148 -0
- package/bin/skills/unsloth/docs/kernels-packing.md +190 -0
- package/bin/skills/unsloth/docs/kimi-k2.5.md +634 -0
- package/bin/skills/unsloth/docs/lm-studio.md +235 -0
- package/bin/skills/unsloth/docs/lora-hot-swapping.md +75 -0
- package/bin/skills/unsloth/docs/lora-hyperparameters.md +363 -0
- package/bin/skills/unsloth/docs/memory-efficient-rl.md +267 -0
- package/bin/skills/unsloth/docs/model-selection.md +70 -0
- package/bin/skills/unsloth/docs/models.md +532 -0
- package/bin/skills/unsloth/docs/multi-gpu-ddp.md +90 -0
- package/bin/skills/unsloth/docs/notebooks.md +223 -0
- package/bin/skills/unsloth/docs/overview.md +110 -0
- package/bin/skills/unsloth/docs/qwen3-coder-next-extended.md +900 -0
- package/bin/skills/unsloth/docs/qwen3-coder-next.md +900 -0
- package/bin/skills/unsloth/docs/requirements.md +45 -0
- package/bin/skills/unsloth/docs/reward-hacking.md +25 -0
- package/bin/skills/unsloth/docs/saving-to-gguf.md +138 -0
- package/bin/skills/unsloth/docs/saving-to-ollama.md +46 -0
- package/bin/skills/unsloth/docs/sglang-guide.md +278 -0
- package/bin/skills/unsloth/docs/speculative-decoding.md +70 -0
- package/bin/skills/unsloth/docs/tool-calling.md +334 -0
- package/bin/skills/unsloth/docs/troubleshooting-faq.md +204 -0
- package/bin/skills/unsloth/docs/troubleshooting-inference.md +26 -0
- package/bin/skills/unsloth/docs/tts-fine-tuning.md +149 -0
- package/bin/skills/unsloth/docs/tutorial-grpo.md +273 -0
- package/bin/skills/unsloth/docs/tutorial-llama3-ollama.md +356 -0
- package/bin/skills/unsloth/docs/vision-fine-tuning.md +135 -0
- package/bin/skills/unsloth/docs/vision-rl.md +170 -0
- package/bin/skills/unsloth/docs/vllm-engine-arguments.md +43 -0
- package/bin/skills/unsloth/docs/vllm-guide.md +98 -0
- package/bin/skills/venue-templates/SKILL.md +686 -0
- package/bin/skills/venue-templates/assets/examples/cell_summary_example.md +247 -0
- package/bin/skills/venue-templates/assets/examples/medical_structured_abstract.md +313 -0
- package/bin/skills/venue-templates/assets/examples/nature_abstract_examples.md +213 -0
- package/bin/skills/venue-templates/assets/examples/neurips_introduction_example.md +245 -0
- package/bin/skills/venue-templates/assets/grants/nih_specific_aims.tex +235 -0
- package/bin/skills/venue-templates/assets/grants/nsf_proposal_template.tex +375 -0
- package/bin/skills/venue-templates/assets/journals/nature_article.tex +171 -0
- package/bin/skills/venue-templates/assets/journals/neurips_article.tex +283 -0
- package/bin/skills/venue-templates/assets/journals/plos_one.tex +317 -0
- package/bin/skills/venue-templates/assets/posters/beamerposter_academic.tex +311 -0
- package/bin/skills/venue-templates/references/cell_press_style.md +483 -0
- package/bin/skills/venue-templates/references/conferences_formatting.md +564 -0
- package/bin/skills/venue-templates/references/cs_conference_style.md +463 -0
- package/bin/skills/venue-templates/references/grants_requirements.md +787 -0
- package/bin/skills/venue-templates/references/journals_formatting.md +486 -0
- package/bin/skills/venue-templates/references/medical_journal_styles.md +535 -0
- package/bin/skills/venue-templates/references/ml_conference_style.md +556 -0
- package/bin/skills/venue-templates/references/nature_science_style.md +405 -0
- package/bin/skills/venue-templates/references/posters_guidelines.md +628 -0
- package/bin/skills/venue-templates/references/reviewer_expectations.md +417 -0
- package/bin/skills/venue-templates/references/venue_writing_styles.md +321 -0
- package/bin/skills/venue-templates/scripts/customize_template.py +195 -0
- package/bin/skills/venue-templates/scripts/query_template.py +266 -0
- package/bin/skills/venue-templates/scripts/validate_format.py +250 -0
- package/bin/synsc +0 -0
- package/package.json +1 -1
- package/bin/skills/unsloth/references/index.md +0 -7
- package/bin/skills/unsloth/references/llms-full.md +0 -16799
- package/bin/skills/unsloth/references/llms-txt.md +0 -12044
- package/bin/skills/unsloth/references/llms.md +0 -82
|
@@ -0,0 +1,997 @@
|
|
|
1
|
+
# GLM-4.7-Flash: How To Run Locally
|
|
2
|
+
|
|
3
|
+
GLM-4.7-Flash is Z.ai’s new 30B MoE reasoning model built for local deployment, delivering best-in-class performance for coding, agentic workflows, and chat. It uses \~3.6B parameters, supports 200K context, and leads SWE-Bench, GPQA, and reasoning/chat benchmarks.
|
|
4
|
+
|
|
5
|
+
GLM-4.7-Flash runs on **24GB RAM**/VRAM/unified memory (32GB for full precision), and you can now fine-tune with Unsloth. To run GLM 4.7 Flash with vLLM, see [#glm-4.7-flash-in-vllm](#glm-4.7-flash-in-vllm "mention")
|
|
6
|
+
|
|
7
|
+
{% hint style="success" %}
|
|
8
|
+
Jan 21 update: `llama.cpp` fixed a bug specifying the wrong `scoring_func`: `"softmax"` (should be `"sigmoid"`). This caused looping and poor outputs. We updated the GGUFs - please re-download the model for much better outputs.
|
|
9
|
+
|
|
10
|
+
You can now use Z.ai’s recommended parameters and get great results:
|
|
11
|
+
|
|
12
|
+
* **For general use-case:** `--temp 1.0 --top-p 0.95`
|
|
13
|
+
* **For tool-calling:** `--temp 0.7 --top-p 1.0`
|
|
14
|
+
* **Repeat penalty:** Disable it, or set `--repeat-penalty 1.Jan 22: Faster inference is here as the FA fix for CUDA is now merged.
|
|
15
|
+
{% endhint %}
|
|
16
|
+
|
|
17
|
+
<a href="#run-glm-4.7-flash" class="button primary">Running Tutorial</a><a href="#fine-tuning-glm-4.7-flash" class="button secondary">Fine-tuning</a>
|
|
18
|
+
|
|
19
|
+
GLM-4.7-Flash GGUF to run: [unsloth/GLM-4.7-Flash-GGUF](https://huggingface.co/unsloth/GLM-4.7-Flash-GGUF)
|
|
20
|
+
|
|
21
|
+
### ⚙️ Usage Guide
|
|
22
|
+
|
|
23
|
+
After speaking with the Z.ai's team, they recommend using their GLM-4.7 sampling parameters:
|
|
24
|
+
|
|
25
|
+
| Default Settings (Most Tasks) | Terminal Bench, SWE Bench Verified |
|
|
26
|
+
| ------------------------------------------------------------------ | ------------------------------------------------------------------ |
|
|
27
|
+
| <mark style="background-color:green;">**temperature = 1.0**</mark> | <mark style="background-color:green;">**temperature = 0.7**</mark> |
|
|
28
|
+
| <mark style="background-color:green;">**top\_p = 0.95**</mark> | <mark style="background-color:green;">**top\_p = 1.0**</mark> |epeat penalty = disabled or 1.0 | repeat penalty = disabled or 1.0 |
|
|
29
|
+
|
|
30
|
+
* For general use-case: `--temp 1.0 --top-p 0.95`
|
|
31
|
+
* For tool-calling: `--temp 0.7 --top-p 1.0`
|
|
32
|
+
* If using llama.cpp, set `--min-p 0.01` as llama.cpp's default is 0.05
|
|
33
|
+
* Sometimes you'll need to experiment what numbers work best for your use-case.
|
|
34
|
+
|
|
35
|
+
{% hint style="warning" %}
|
|
36
|
+
For now, we **don’t recommend** running this GGUF with **Ollama** due to potential chat template compatibility issues. The GGUF works well on llama.cpp (or backends e.g. LM Studio, Jan).
|
|
37
|
+
|
|
38
|
+
**Remember to disable repeat penalty! Or set** `--repeat-penalty 1.0`
|
|
39
|
+
{% endhint %}
|
|
40
|
+
|
|
41
|
+
* **Maximum context window:** `202,752`
|
|
42
|
+
* Use `--jinja` for llama.cpp variants
|
|
43
|
+
|
|
44
|
+
### 🖥️ Run GLM-4.7-Flash
|
|
45
|
+
|
|
46
|
+
Depending on your use-case you will need to use different settings. Some GGUFs end up similar in size because the model architecture (like [gpt-oss](https://unsloth.ai/docs/models/gpt-oss-how-to-run-and-fine-tune)) has dins not divisible by 128, so parts can’t be quantized to lower bits.
|
|
47
|
+
|
|
48
|
+
Because this guide uses 4-bit, you will need around 18GB RAM/unified memory. We recommend using at least 4-bit precision for best performance.
|
|
49
|
+
|
|
50
|
+
{% hint style="warning" %}
|
|
51
|
+
For now, we **don’t recommend** running this GGUF with **Ollama** due to potential chat template compatibility issues. The GGUF works well on llama.cpp (or backends e.g. LM Studio, Jan).
|
|
52
|
+
|
|
53
|
+
**Remember to disable repeat penalty! Or set** `--repeat-penalty 1.0`
|
|
54
|
+
{% endhint %}
|
|
55
|
+
|
|
56
|
+
#### Llama.cpp Tutorial (GGUF):
|
|
57
|
+
|
|
58
|
+
Instructions to run in llama.cpp (note we will be using 4-bit to fit most devices):
|
|
59
|
+
|
|
60
|
+
{% stepper %}
|
|
61
|
+
{% step %}
|
|
62
|
+
Obtain the latest `llama.cpp` on [GitHub here](https://github.com/ggml-org/llama.cpp). You can follow the build instructions below as well. Change `-DGGML_CUDA=ON` to `-DGGML_CUDA=OFF` if you don't have a GPU or just want CPU inference.
|
|
63
|
+
|
|
64
|
+
{% code overflow="wrap" %}
|
|
65
|
+
|
|
66
|
+
```bash
|
|
67
|
+
apt-get update
|
|
68
|
+
apt-get install pciutils build-essential cmake curl libcurl4-openssl-dev it clone https://github.com/ggml-org/llama.cpp
|
|
69
|
+
cmake llama.cpp -B llama.cpp/build \
|
|
70
|
+
-DBUILD_SHARED_LIBS=OFF -DGGML_CUDA=ON
|
|
71
|
+
cmake --build llama.cpp/build --config Release -j --clean-first --target llama-cli llama-mtmd-cli llama-server llama-gguf-split
|
|
72
|
+
cp llama.cpp/build/bin/llama-* llama.cpp
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
{% endcode %}
|
|
76
|
+
{% endstep %}
|
|
77
|
+
|
|
78
|
+
{% step %}
|
|
79
|
+
You can directly pull from Hugging Face. You can increase the context to 200K as your RAM/VRAM allows.
|
|
80
|
+
|
|
81
|
+
You can also try Z.ai's recommended GLM-4.7 sampling parameters:
|
|
82
|
+
|
|
83
|
+
* For general use-case: `--temp 1.0 --top-p 0.95`
|
|
84
|
+
* For tool-calling: `--temp 0.7 --top-p 1.0`
|
|
85
|
+
* **Remember to disable repeat penalty!**
|
|
86
|
+
|
|
87
|
+
Follow this for **general instruction** use-cases:
|
|
88
|
+
|
|
89
|
+
```bash
|
|
90
|
+
./llama.cpp/llama-cli \
|
|
91
|
+
-hf unsloth/GLM-4.7-Flash-GGUF:UD-Q4_K_XL \
|
|
92
|
+
--jinja --ctx-size 16384 \
|
|
93
|
+
--temp 1.0 --top-p 0.95 --min-p 0.01 --fit on
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
Follow this for **tool-calling** use-cases:
|
|
97
|
+
|
|
98
|
+
```bash
|
|
99
|
+
./llama.cpp/llama-cli \
|
|
100
|
+
-hf unsloth/GLM-4.7-Flash-GGUF:UD-Q4_K_XL \
|
|
101
|
+
--jinja --ctx-size 16384 \
|
|
102
|
+
--temp 0.7 --top-p 1.0 --min-p 0.01 --fit on
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
{% endstep %}
|
|
106
|
+
|
|
107
|
+
{% step %}
|
|
108
|
+
Download the model via (after installing `pip install huggingface_hub`). You can choose `UD-Q4_K_XL` or other quantized versions.
|
|
109
|
+
|
|
110
|
+
{% code overflow="wrap" %}
|
|
111
|
+
|
|
112
|
+
```bash
|
|
113
|
+
pip install -U huggingface_hub
|
|
114
|
+
hf download unsloth/GLM-4.7-Flash-GGUF \
|
|
115
|
+
--local-dir unsloth/GLM-4.7-Flash-GGUF \
|
|
116
|
+
--include "*UD-Q2_K_XL*"
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
{% endcode %}
|
|
120
|
+
{% endstep %}
|
|
121
|
+
|
|
122
|
+
{% step %}
|
|
123
|
+
Then run the model in conversation mode:
|
|
124
|
+
|
|
125
|
+
{% code overflow="wrap" %}
|
|
126
|
+
|
|
127
|
+
```bash
|
|
128
|
+
./llama.cpp/llama-cli \
|
|
129
|
+
--model unsloth/GLM-4.7-Flash-GGUF/GLM-4.7-Flash-UD-Q4_K_XL.gguf \
|
|
130
|
+
--ctx-size 16384 \
|
|
131
|
+
--fit on \
|
|
132
|
+
--seed 3407 \
|
|
133
|
+
--temp 1.0 \
|
|
134
|
+
--top-p 0.95 \
|
|
135
|
+
--min-p 0.01 \
|
|
136
|
+
--jinja
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
{% endcode %}
|
|
140
|
+
|
|
141
|
+
Also, adjust **context window** as required, up to `202752`
|
|
142
|
+
{% endstep %}
|
|
143
|
+
{% endstepper %}
|
|
144
|
+
|
|
145
|
+
### :loop:Reducing repetition and looping
|
|
146
|
+
|
|
147
|
+
{% hint style="success" %}
|
|
148
|
+
**JAN 21 UPDATE: llama.cpp fixed a bug specifying the wrong** `"scoring_func": "softmax"` **that caused looping and poor outputs (should be sigmoid) We updated the GGUFs. Please re-download the model for much better outputs.**
|
|
149
|
+
{% endhint %}
|
|
150
|
+
|
|
151
|
+
This means you can now use Z.ai's recommended parameters and get great results:
|
|
152
|
+
|
|
153
|
+
* For general use-case: `--temp 1.0 --top-p 0.95`
|
|
154
|
+
* For tool-calling: `--temp 0.7 --top-p 1.0`
|
|
155
|
+
* If using llama.cpp, set `--min-p 0.01` as llama.cpp's default is 0.05
|
|
156
|
+
* **Remember to disable repeat penalty! Or set** `--repeat-penalty 1.0`
|
|
157
|
+
|
|
158
|
+
We added `"scoring_func": "sigmoid"` to `config.json` for the main model - [see](https://huggingface.co/unsloth/GLM-4.7-Flash/commit/3fd53b491e04f707f307aef2f70f8a7520511e6d).
|
|
159
|
+
|
|
160
|
+
{% hint style="warning" %}
|
|
161
|
+
For now, we **don’t recommend** running this GGUF with **Ollama** due to potential chat template compatibility issues. The GGUF works well on llama.cpp (or backends e.g. LM Studio, Jan).
|
|
162
|
+
{% endhint %}
|
|
163
|
+
|
|
164
|
+
### :bird:Flappy Bird Example with UD-Q4\_K\_XL
|
|
165
|
+
|
|
166
|
+
As an example, we did the following long conversation by using UD-Q4\_K\_XL via `./llama.cpp/llama-cli model unsloth/GLM-4.7-Flash-GGUF/GLM-4.7-Flash-UD-Q4_K_XL.gguf --fit on --temp 1.0 --top-p 0.95 --min-p 0.01 --jinja` :
|
|
167
|
+
|
|
168
|
+
```
|
|
169
|
+
Hi
|
|
170
|
+
What is 2+2
|
|
171
|
+
Create a Python Flappy Bird game
|
|
172
|
+
Create a totally different game in Rust
|
|
173
|
+
Find bugs in both
|
|
174
|
+
Make the 1st game I mentioned but in a standalone HTML file
|
|
175
|
+
Find bugs and show the fixed game
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
which rendered the following Flappy Bird game in HTML form:
|
|
179
|
+
|
|
180
|
+
<details>
|
|
181
|
+
|
|
182
|
+
<summary>Flappy Bird Game in HTML (Expandable)</summary>
|
|
183
|
+
|
|
184
|
+
```html
|
|
185
|
+
<!DOCTYPE html>
|
|
186
|
+
<html lang="en">
|
|
187
|
+
<head>
|
|
188
|
+
<meta charset="UTF-8">
|
|
189
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
|
|
190
|
+
<title>Flappy Bird Fixed</title>
|
|
191
|
+
<style>
|
|
192
|
+
body {
|
|
193
|
+
margin: 0;
|
|
194
|
+
display: flex;
|
|
195
|
+
justify-content: center;
|
|
196
|
+
align-items: center;
|
|
197
|
+
height: 100vh;
|
|
198
|
+
background-color: #222;
|
|
199
|
+
font-family: 'Arial', sans-serif;
|
|
200
|
+
overflow: hidden;
|
|
201
|
+
user-select: none;
|
|
202
|
+
-webkit-user-select: none;
|
|
203
|
+
touch-action: none; /* Prevents zoom on mobile */
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
#game-container {
|
|
207
|
+
position: relative;
|
|
208
|
+
box-shadow: 0 0 20px rgba(0,0,0,0.5);
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
canvas {
|
|
212
|
+
background-color: #87CEEB;
|
|
213
|
+
display: block;
|
|
214
|
+
border-radius: 4px;
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
/* UI Overlays */
|
|
218
|
+
#ui-layer {
|
|
219
|
+
position: absolute;
|
|
220
|
+
top: 0;
|
|
221
|
+
left: 0;
|
|
222
|
+
width: 100%;
|
|
223
|
+
height: 100%;
|
|
224
|
+
pointer-events: none;
|
|
225
|
+
display: flex;
|
|
226
|
+
flex-direction: column;
|
|
227
|
+
justify-content: center;
|
|
228
|
+
align-items: center;
|
|
229
|
+
text-align: center;
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
#score-display {
|
|
233
|
+
position: absolute;
|
|
234
|
+
top: 40px;
|
|
235
|
+
left: 50%;
|
|
236
|
+
transform: translateX(-50%);
|
|
237
|
+
font-size: 48px;
|
|
238
|
+
font-weight: bold;
|
|
239
|
+
color: white;
|
|
240
|
+
text-shadow: 3px 3px 0 #000;
|
|
241
|
+
z-index: 10;
|
|
242
|
+
font-family: 'Courier New', Courier, monospace;
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
#start-screen, #game-over-screen {
|
|
246
|
+
background: rgba(0, 0, 0, 0.7);
|
|
247
|
+
width: 100%;
|
|
248
|
+
height: 100%;
|
|
249
|
+
display: flex;
|
|
250
|
+
flex-direction: column;
|
|
251
|
+
justify-content: center;
|
|
252
|
+
align-items: center;
|
|
253
|
+
color: white;
|
|
254
|
+
pointer-events: auto; /* Allow clicks */
|
|
255
|
+
cursor: pointer;
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
h1 { margin: 0 0 10px 0; font-size: 60px; text-shadow: 4px 4px 0 #000; line-height: 1; }
|
|
259
|
+
p { font-size: 22px; margin: 10px 0; color: #ddd; }
|
|
260
|
+
|
|
261
|
+
.btn {
|
|
262
|
+
background: linear-gradient(to bottom, #ffeb3b, #fbc02d);
|
|
263
|
+
border: 3px solid #fff;
|
|
264
|
+
color: #333;
|
|
265
|
+
padding: 15px 40px;
|
|
266
|
+
font-size: 28px;
|
|
267
|
+
font-weight: bold;
|
|
268
|
+
cursor: pointer;
|
|
269
|
+
border-radius: 8px;
|
|
270
|
+
box-shadow: 0 6px 0 #c49000, 0 10px 10px rgba(0,0,0,0.3);
|
|
271
|
+
text-transform: uppercase;
|
|
272
|
+
transition: all 0.1s;
|
|
273
|
+
margin-top: 10px;
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
.btn:active {
|
|
277
|
+
transform: translateY(4px);
|
|
278
|
+
box-shadow: 0 2px 0 #c49000, 0 4px 4px rgba(0,0,0,0.3);
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
.score-board {
|
|
282
|
+
background: #ded895;
|
|
283
|
+
border: 2px solid #543847;
|
|
284
|
+
padding: 20px 40px;
|
|
285
|
+
border-radius: 10px;
|
|
286
|
+
box-shadow: 4px 4px 0 #543847;
|
|
287
|
+
margin-bottom: 30px;
|
|
288
|
+
display: none;
|
|
289
|
+
border: 4px solid #543847;
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
.score-board h2 { margin: 0 0 5px 0; color: #e86101; font-size: 40px; }
|
|
293
|
+
.score-board span { font-size: 20px; color: #543847; display: block; text-align: center; }
|
|
294
|
+
|
|
295
|
+
</style>
|
|
296
|
+
</head>
|
|
297
|
+
<body>
|
|
298
|
+
|
|
299
|
+
<div id="game-container">
|
|
300
|
+
<canvas id="gameCanvas" width="400" height="600"></canvas>
|
|
301
|
+
|
|
302
|
+
<div id="score-display">0</div>
|
|
303
|
+
|
|
304
|
+
<div id="ui-layer">
|
|
305
|
+
<div id="start-screen">
|
|
306
|
+
<h1>FLAPPY<br>BIRD</h1>
|
|
307
|
+
<p>Tap or Press Space to Start</p>
|
|
308
|
+
<button class="btn" style="display:none;" id="touch-instruction">Click to Start</button>
|
|
309
|
+
</div>
|
|
310
|
+
|
|
311
|
+
<div id="game-over-screen">
|
|
312
|
+
<h1>GAME OVER</h1>
|
|
313
|
+
<div class="score-board" id="score-board">
|
|
314
|
+
<h2>Score: <span id="final-score">0</span></h2>
|
|
315
|
+
</div>
|
|
316
|
+
<button class="btn" id="restart-btn">Try Again</button>
|
|
317
|
+
</div>
|
|
318
|
+
</div>
|
|
319
|
+
</div>
|
|
320
|
+
|
|
321
|
+
<script>
|
|
322
|
+
const canvas = document.getElementById('gameCanvas');
|
|
323
|
+
const ctx = canvas.getContext('2d');
|
|
324
|
+
|
|
325
|
+
// --- Constants ---
|
|
326
|
+
const GRAVITY = 0.35; // Slightly harder gravity for better feel
|
|
327
|
+
const JUMP_STRENGTH = -6.5;
|
|
328
|
+
const PIPE_GAP = 180;
|
|
329
|
+
const PIPE_WIDTH = 60;
|
|
330
|
+
const PIPE_SPEED = 2.5;
|
|
331
|
+
const PIPE_SPAWN_RATE = 100;
|
|
332
|
+
|
|
333
|
+
// --- State ---
|
|
334
|
+
let frames = 0;
|
|
335
|
+
let score = 0;
|
|
336
|
+
let isGameOver = false;
|
|
337
|
+
let isPlaying = false;
|
|
338
|
+
let gameLoopId;
|
|
339
|
+
|
|
340
|
+
const ui = {
|
|
341
|
+
startScreen: document.getElementById('start-screen'),
|
|
342
|
+
gameOverScreen: document.getElementById('game-over-screen'),
|
|
343
|
+
scoreDisplay: document.getElementById('score-display'),
|
|
344
|
+
scoreBoard: document.getElementById('score-board'),
|
|
345
|
+
finalScore: document.getElementById('final-score'),
|
|
346
|
+
restartBtn: document.getElementById('restart-btn')
|
|
347
|
+
};
|
|
348
|
+
|
|
349
|
+
const bird = {
|
|
350
|
+
x: 80,
|
|
351
|
+
y: 150,
|
|
352
|
+
radius: 12, // Fixed radius
|
|
353
|
+
velocity: 0,
|
|
354
|
+
|
|
355
|
+
draw: function() {
|
|
356
|
+
// Rotate bird based on velocity for visual flair
|
|
357
|
+
let angle = Math.min(Math.PI / 4, Math.max(-Math.PI / 4, (this.velocity * 0.1)));
|
|
358
|
+
|
|
359
|
+
ctx.save();
|
|
360
|
+
ctx.translate(this.x, this.y);
|
|
361
|
+
ctx.rotate(angle);
|
|
362
|
+
|
|
363
|
+
// Draw Body
|
|
364
|
+
ctx.fillStyle = '#FFD700';
|
|
365
|
+
ctx.beginPath();
|
|
366
|
+
ctx.arc(0, 0, this.radius, 0, Math.PI * 2);
|
|
367
|
+
ctx.fill();
|
|
368
|
+
|
|
369
|
+
// Eye
|
|
370
|
+
ctx.fillStyle = 'white';
|
|
371
|
+
ctx.beginPath();
|
|
372
|
+
ctx.arc(4, -4, 4, 0, Math.PI * 2);
|
|
373
|
+
ctx.fill();
|
|
374
|
+
ctx.fillStyle = 'black';
|
|
375
|
+
ctx.beginPath();
|
|
376
|
+
ctx.arc(6, -4, 2, 0, Math.PI * 2);
|
|
377
|
+
ctx.fill();
|
|
378
|
+
|
|
379
|
+
// Wing
|
|
380
|
+
ctx.fillStyle = '#FFA500';
|
|
381
|
+
ctx.beginPath();
|
|
382
|
+
ctx.arc(-4, 4, 5, 0, Math.PI * 2);
|
|
383
|
+
ctx.fill();
|
|
384
|
+
|
|
385
|
+
ctx.restore();
|
|
386
|
+
},
|
|
387
|
+
|
|
388
|
+
update: function() {
|
|
389
|
+
this.velocity += GRAVITY;
|
|
390
|
+
this.y += this.velocity;
|
|
391
|
+
},
|
|
392
|
+
|
|
393
|
+
jump: function() {
|
|
394
|
+
this.velocity = JUMP_STRENGTH;
|
|
395
|
+
},
|
|
396
|
+
|
|
397
|
+
reset: function() {
|
|
398
|
+
this.y = 150;
|
|
399
|
+
this.velocity = 0;
|
|
400
|
+
}
|
|
401
|
+
};
|
|
402
|
+
|
|
403
|
+
let pipes = [];
|
|
404
|
+
|
|
405
|
+
function createPipe() {
|
|
406
|
+
const minHeight = 50;
|
|
407
|
+
const maxPos = canvas.height - PIPE_GAP - minHeight;
|
|
408
|
+
const topHeight = Math.floor(Math.random() * (maxPos - minHeight + 1)) + minHeight;
|
|
409
|
+
|
|
410
|
+
pipes.push({
|
|
411
|
+
x: canvas.width,
|
|
412
|
+
topHeight: topHeight,
|
|
413
|
+
bottomY: topHeight + PIPE_GAP,
|
|
414
|
+
width: PIPE_WIDTH,
|
|
415
|
+
passed: false
|
|
416
|
+
});
|
|
417
|
+
}
|
|
418
|
+
|
|
419
|
+
function drawPipes() {
|
|
420
|
+
ctx.fillStyle = '#2ecc71';
|
|
421
|
+
ctx.strokeStyle = '#27ae60';
|
|
422
|
+
ctx.lineWidth = 2;
|
|
423
|
+
|
|
424
|
+
pipes.forEach(pipe => {
|
|
425
|
+
// Top Pipe
|
|
426
|
+
ctx.fillRect(pipe.x, 0, pipe.width, pipe.topHeight);
|
|
427
|
+
ctx.strokeRect(pipe.x, 0, pipe.width, pipe.topHeight);
|
|
428
|
+
|
|
429
|
+
// Bottom Pipe
|
|
430
|
+
ctx.fillRect(pipe.x, pipe.bottomY, pipe.width, canvas.height - pipe.bottomY);
|
|
431
|
+
ctx.strokeRect(pipe.x, pipe.bottomY, pipe.width, canvas.height - pipe.bottomY);
|
|
432
|
+
|
|
433
|
+
// Cap
|
|
434
|
+
const capH = 20;
|
|
435
|
+
ctx.fillStyle = '#27ae60';
|
|
436
|
+
ctx.fillRect(pipe.x - 2, pipe.topHeight - capH, pipe.width + 4, capH);
|
|
437
|
+
ctx.fillRect(pipe.x - 2, pipe.bottomY, pipe.width + 4, capH);
|
|
438
|
+
});
|
|
439
|
+
}
|
|
440
|
+
|
|
441
|
+
function updatePipes() {
|
|
442
|
+
if (frames % PIPE_SPAWN_RATE === 0) createPipe();
|
|
443
|
+
|
|
444
|
+
for (let i = 0; i < pipes.length; i++) {
|
|
445
|
+
let p = pipes[i];
|
|
446
|
+
p.x -= PIPE_SPEED;
|
|
447
|
+
|
|
448
|
+
// --- FIXED COLLISION DETECTION ---
|
|
449
|
+
// Treat bird as a circle of radius 'bird.radius'
|
|
450
|
+
// Pipe is a rect: x, x+w, y_top, y_bottom
|
|
451
|
+
let birdLeft = bird.x - bird.radius;
|
|
452
|
+
let birdRight = bird.x + bird.radius;
|
|
453
|
+
let birdTop = bird.y - bird.radius;
|
|
454
|
+
let birdBottom = bird.y + bird.radius;
|
|
455
|
+
|
|
456
|
+
// Horizontal Overlap
|
|
457
|
+
if (birdRight > p.x && birdLeft < p.x + p.width) {
|
|
458
|
+
// Vertical Overlap (Hit Top Pipe OR Hit Bottom Pipe)
|
|
459
|
+
if (birdTop < p.topHeight || birdBottom > p.bottomY) {
|
|
460
|
+
gameOver();
|
|
461
|
+
}
|
|
462
|
+
}
|
|
463
|
+
|
|
464
|
+
// --- FIXED SCORING ---
|
|
465
|
+
// If pipe is off screen to the left, and hasn't been scored
|
|
466
|
+
if (p.x + p.width < 0 && !p.passed) {
|
|
467
|
+
score++;
|
|
468
|
+
p.passed = true;
|
|
469
|
+
ui.scoreDisplay.innerText = score;
|
|
470
|
+
}
|
|
471
|
+
|
|
472
|
+
if (p.x < -60) {
|
|
473
|
+
pipes.shift();
|
|
474
|
+
i--;
|
|
475
|
+
}
|
|
476
|
+
}
|
|
477
|
+
}
|
|
478
|
+
|
|
479
|
+
function checkCollisions() {
|
|
480
|
+
// Floor
|
|
481
|
+
if (bird.y + bird.radius >= canvas.height) {
|
|
482
|
+
gameOver();
|
|
483
|
+
}
|
|
484
|
+
// Ceiling
|
|
485
|
+
if (bird.y - bird.radius <= 0) {
|
|
486
|
+
bird.y = bird.radius;
|
|
487
|
+
bird.velocity = 0;
|
|
488
|
+
}
|
|
489
|
+
}
|
|
490
|
+
|
|
491
|
+
function drawBackground() {
|
|
492
|
+
// Clear
|
|
493
|
+
ctx.clearRect(0, 0, canvas.width, canvas.height);
|
|
494
|
+
|
|
495
|
+
// Floor
|
|
496
|
+
ctx.fillStyle = '#654321';
|
|
497
|
+
ctx.fillRect(0, canvas.height - 10, canvas.width, 10);
|
|
498
|
+
|
|
499
|
+
// Clouds
|
|
500
|
+
ctx.fillStyle = "rgba(255, 255, 255, 0.6)";
|
|
501
|
+
for(let i=0; i<4; i++) {
|
|
502
|
+
let x = (frames * 0.5 + i * 150) % (canvas.width + 100) - 50;
|
|
503
|
+
let y = (i * 40) + 20;
|
|
504
|
+
let scale = 1 + (Math.sin(frames * 0.02 + i) * 0.1);
|
|
505
|
+
let size = 30 * scale;
|
|
506
|
+
ctx.beginPath();
|
|
507
|
+
ctx.arc(x, y, size, 0, Math.PI * 2);
|
|
508
|
+
ctx.arc(x + 20*scale, y - 10*scale, size * 1.2, 0, Math.PI * 2);
|
|
509
|
+
ctx.arc(x + 40*scale, y, size, 0, Math.PI * 2);
|
|
510
|
+
ctx.fill();
|
|
511
|
+
}
|
|
512
|
+
}
|
|
513
|
+
|
|
514
|
+
function update() {
|
|
515
|
+
if (!isPlaying) return;
|
|
516
|
+
bird.update();
|
|
517
|
+
updatePipes();
|
|
518
|
+
checkCollisions();
|
|
519
|
+
frames++;
|
|
520
|
+
}
|
|
521
|
+
|
|
522
|
+
function draw() {
|
|
523
|
+
drawBackground();
|
|
524
|
+
drawPipes();
|
|
525
|
+
bird.draw();
|
|
526
|
+
}
|
|
527
|
+
|
|
528
|
+
function loop() {
|
|
529
|
+
update();
|
|
530
|
+
draw();
|
|
531
|
+
if (isPlaying || !isGameOver) {
|
|
532
|
+
gameLoopId = requestAnimationFrame(loop);
|
|
533
|
+
}
|
|
534
|
+
}
|
|
535
|
+
|
|
536
|
+
function startGame() {
|
|
537
|
+
isPlaying = true;
|
|
538
|
+
isGameOver = false;
|
|
539
|
+
|
|
540
|
+
// UI
|
|
541
|
+
ui.startScreen.style.display = 'none';
|
|
542
|
+
ui.gameOverScreen.style.display = 'none';
|
|
543
|
+
ui.scoreBoard.style.display = 'none';
|
|
544
|
+
|
|
545
|
+
// Logic
|
|
546
|
+
bird.reset();
|
|
547
|
+
pipes = [];
|
|
548
|
+
score = 0;
|
|
549
|
+
frames = 0;
|
|
550
|
+
ui.scoreDisplay.innerText = '0';
|
|
551
|
+
|
|
552
|
+
loop();
|
|
553
|
+
}
|
|
554
|
+
|
|
555
|
+
function gameOver() {
|
|
556
|
+
isPlaying = false;
|
|
557
|
+
isGameOver = true;
|
|
558
|
+
cancelAnimationFrame(gameLoopId);
|
|
559
|
+
|
|
560
|
+
ui.finalScore.innerText = score;
|
|
561
|
+
ui.gameOverScreen.style.display = 'flex';
|
|
562
|
+
ui.scoreBoard.style.display = 'block';
|
|
563
|
+
}
|
|
564
|
+
|
|
565
|
+
// --- Input Handling ---
|
|
566
|
+
|
|
567
|
+
function handleInput(e) {
|
|
568
|
+
if (e.type === 'keydown' && e.code === 'Space') e.preventDefault();
|
|
569
|
+
|
|
570
|
+
if (isPlaying) {
|
|
571
|
+
bird.jump();
|
|
572
|
+
} else if (!isGameOver) {
|
|
573
|
+
// Click on start screen (or any click if game hasn't started)
|
|
574
|
+
startGame();
|
|
575
|
+
}
|
|
576
|
+
}
|
|
577
|
+
|
|
578
|
+
// Keyboard
|
|
579
|
+
window.addEventListener('keydown', (e) => {
|
|
580
|
+
if (e.code === 'Space') handleInput(e);
|
|
581
|
+
});
|
|
582
|
+
|
|
583
|
+
// Mouse / Touch
|
|
584
|
+
window.addEventListener('mousedown', handleInput);
|
|
585
|
+
window.addEventListener('touchstart', (e) => {
|
|
586
|
+
// Prevent zoom/scroll
|
|
587
|
+
// e.preventDefault();
|
|
588
|
+
handleInput(e);
|
|
589
|
+
}, {passive: false});
|
|
590
|
+
|
|
591
|
+
// UI Interactions
|
|
592
|
+
ui.restartBtn.addEventListener('click', (e) => {
|
|
593
|
+
e.stopPropagation();
|
|
594
|
+
startGame();
|
|
595
|
+
});
|
|
596
|
+
|
|
597
|
+
// Allow clicking the Game Over overlay to restart
|
|
598
|
+
ui.gameOverScreen.addEventListener('mousedown', (e) => {
|
|
599
|
+
if(e.target === ui.gameOverScreen) startGame();
|
|
600
|
+
});
|
|
601
|
+
ui.gameOverScreen.addEventListener('touchstart', (e) => {
|
|
602
|
+
if(e.target === ui.gameOverScreen) {
|
|
603
|
+
e.preventDefault();
|
|
604
|
+
startGame();
|
|
605
|
+
}
|
|
606
|
+
});
|
|
607
|
+
|
|
608
|
+
// Initial Draw
|
|
609
|
+
drawBackground();
|
|
610
|
+
bird.reset();
|
|
611
|
+
bird.draw();
|
|
612
|
+
|
|
613
|
+
</script>
|
|
614
|
+
</body>
|
|
615
|
+
</html>
|
|
616
|
+
```
|
|
617
|
+
|
|
618
|
+
</details>
|
|
619
|
+
|
|
620
|
+
And we took some screenshots (4bit works):
|
|
621
|
+
|
|
622
|
+
<div align="left"><figure><img src="https://3215535692-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FxhOjnexMCB3dmuQFQ2Zq%2Fuploads%2FJ85uzHPDWinaXPe6kWyU%2Fimage.png?alt=media&token=6547f49d-2544-4c48-a7d5-5c1c67d34a87" alt="" width="188"><figcaption></figcaption></figure> <figure><img src="https://3215535692-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FxhOjnexMCB3dmuQFQ2Zq%2Fuploads%2FHAc2SjNLo1OsyAC4dArm%2Fimage.png?alt=media&token=87d4bfea-4ac9-41ef-be1c-1e51664d30b1" alt="" width="188"><figcaption></figcaption></figure></div>
|
|
623
|
+
|
|
624
|
+
### 🦥 Fine-tuning GLM-4.7-Flash
|
|
625
|
+
|
|
626
|
+
Unsloth now supports fine-tuning of GLM-4.7-Flash, however you will need to use `transformers v5`. The 30B model does not fit on a free Colab GPU; however, you can use our notebook. 16-bit LoRA fine-tuning of GLM-4.7-Flash will use around **60GB VRAM**:
|
|
627
|
+
|
|
628
|
+
* [GLM-4.7-Flash SFT LoRA notebook](https://colab.research.google.com/github/unslothai/notebooks/blob/main/nb/GLM_Flash_A100\(80GB\).ipynb)
|
|
629
|
+
|
|
630
|
+
{% hint style="warning" %}
|
|
631
|
+
You may encounter out of memory sometimes when using A100 40GB VRAM. You will need to use H100/A100 80GB VRAM for smoother runs.
|
|
632
|
+
{% endhint %}
|
|
633
|
+
|
|
634
|
+
{% embed url="<https://colab.research.google.com/github/unslothai/notebooks/blob/main/nb/GLM_Flash_A100(80GB).ipynb>" %}
|
|
635
|
+
|
|
636
|
+
On fine-tung MoE's, it's probably not a good idea to fine-tune the router layer so we disabled it by default. If you want to maintain its reasoning capabilities (optional), you can use a mix of direct answers and chain-of-thought examples. Use at least <mark style="background-color:green;">75% reasoning</mark> and <mark style="background-color:green;">25% non-reasoning</mark> in your dataset to make the model retain its reasoning capabilities.
|
|
637
|
+
|
|
638
|
+
### 🦙Llama-server serving & deployment
|
|
639
|
+
|
|
640
|
+
To deploy GLM-4.7-Flash for production, we use `llama-server` In a new terminal say via tmux, deploy the model via:
|
|
641
|
+
|
|
642
|
+
{% code overflow="wrap" %}
|
|
643
|
+
|
|
644
|
+
```bash
|
|
645
|
+
./llama.cpp/llama-server \
|
|
646
|
+
--model unsloth/GLM-4.7-Flash-GGUF/GLM-4.7-Flash-UD-Q4_K_XL.gguf \
|
|
647
|
+
--alias "unsloth/GLM-4.7-Flash" \
|
|
648
|
+
--fit on \
|
|
649
|
+
--seed 3407 \
|
|
650
|
+
--temp 1.0 \
|
|
651
|
+
--top-p 0.95 \
|
|
652
|
+
--min-p 0.01 \
|
|
653
|
+
--ctx-size 16384 \
|
|
654
|
+
--port 8001 \
|
|
655
|
+
--jinja
|
|
656
|
+
```
|
|
657
|
+
|
|
658
|
+
{% endcode %}
|
|
659
|
+
|
|
660
|
+
Then in a new terminal, after doing `pip install openai`, do:
|
|
661
|
+
|
|
662
|
+
{% code overflow="wrap" %}
|
|
663
|
+
|
|
664
|
+
`python
|
|
665
|
+
from openai import OpenAI
|
|
666
|
+
import json
|
|
667
|
+
openai_client = OpenAI(
|
|
668
|
+
base_url = "http://127.0.0.1:8001/v1",
|
|
669
|
+
api_key = "sk-no-key-required",
|
|
670
|
+
)
|
|
671
|
+
completion = openai_client.chat.completions.create(
|
|
672
|
+
model = "unsloth/GLM-4.7-Flash",
|
|
673
|
+
messages = [{"role": "user", "content": "What is 2+2?"},],
|
|
674
|
+
)
|
|
675
|
+
print(completion.choices[0].message.content)
|
|
676
|
+
```
|
|
677
|
+
|
|
678
|
+
{% endcode %}
|
|
679
|
+
|
|
680
|
+
Which will print
|
|
681
|
+
|
|
682
|
+
{% code overflow="wrap" %}
|
|
683
|
+
|
|
684
|
+
```
|
|
685
|
+
User asks a simple question: "What is 2+2?" The answer is 4. Provide answer.
|
|
686
|
+
|
|
687
|
+
2 + 2 = 4.
|
|
688
|
+
```
|
|
689
|
+
|
|
690
|
+
{% endcode %}
|
|
691
|
+
|
|
692
|
+
### :computer: GLM-4.7-Flash in vLLM
|
|
693
|
+
|
|
694
|
+
You can now use our new [FP8 Dynamic quant](https://huggingface.co/unsloth/GLM-4.7-Flash-FP8-Dynamic) of the model for premium and fast inference. First install vLLM from nightly:
|
|
695
|
+
|
|
696
|
+
{% code overflow="wrap" %}
|
|
697
|
+
|
|
698
|
+
```bash
|
|
699
|
+
uv pip install --upgrade --force-reinstall vllm --torch-backend=auto --extra-index-url https://wheels.vllm.ai/nightly/cu130
|
|
700
|
+
uv pip install --upgrade --force-reinstall git+https://github.com/huggingface/transformers.git
|
|
701
|
+
uv pip instrce-reinstall numba
|
|
702
|
+
```
|
|
703
|
+
|
|
704
|
+
{% endcode %}
|
|
705
|
+
|
|
706
|
+
Then serve [Unsloth's dynamic FP8 version](https://huggingface.co/unsloth/GLM-4.7-Flash-FP8-Dynamic) of the model. We enabled FP8 to reduce KV cache memory usage by 50%, and on 4 GPUs. If you have 1 GPU, use `CUDA_VISIBLE_DEVICES='0'` and set `--tensor-parallel-size 1` or remove this argument. To disable FP8, remove `--quantization fp8 --kv-cache-dtype fp8`
|
|
707
|
+
|
|
708
|
+
```bash
|
|
709
|
+
export PYTORCH_CUDA_ALLOC_CONF=expandable_segments:False
|
|
710
|
+
CUDA_VISIBLE_DEVICES='0,1,2,3' vllm serve unsloth/GLM-4.7-Flash-FP8-Dynamic \
|
|
711
|
+
--served-model-name unsloth/GLM-4.7-Flash \
|
|
712
|
+
--tensor-parallel-size 4 \
|
|
713
|
+
--tool-call-parser glm47 \
|
|
714
|
+
--reasoning-parser glm45 \
|
|
715
|
+
--enable-auto-tool-choice \
|
|
716
|
+
--dtype bfloat16 \
|
|
717
|
+
--seed 3407 \
|
|
718
|
+
--max-model-len 200000 \
|
|
719
|
+
--gpu-memory-utilization 0.95 \
|
|
720
|
+
--max_num_batched_tokens 16384 \
|
|
721
|
+
--port 8001 \
|
|
722
|
+
--kv-cache-dtype fp8
|
|
723
|
+
```
|
|
724
|
+
|
|
725
|
+
You can then call the served model via the OpenAI API:
|
|
726
|
+
|
|
727
|
+
```python
|
|
728
|
+
from openai import AsyncOpenAI, OpenAI
|
|
729
|
+
openai_api_key = "EMPTY"
|
|
730
|
+
openai_api_base = "http://localhost:8001/v1"
|
|
731
|
+
client = OpenAI( # or AsyncOpenAI
|
|
732
|
+
api_key=openai_api_key,
|
|
733
|
+
base_url=openai_api_base,
|
|
734
|
+
)
|
|
735
|
+
```
|
|
736
|
+
|
|
737
|
+
#### :star: vLLM GLM-4.7-Flash Speculative Decoding
|
|
738
|
+
|
|
739
|
+
We found using the MTP (multi token prediction) module from GLM 4.7 Flash makes generation throughput drop from 13,000 tokens on 1 B200 to 1,300 tokens! (10x slower) On Hopper, it should be fine hopefully.
|
|
740
|
+
|
|
741
|
+
```bash
|
|
742
|
+
--speculative-config.method mtp \
|
|
743
|
+
--speculative-config.num_speculative_tokens 1
|
|
744
|
+
```
|
|
745
|
+
|
|
746
|
+
Only 1,300 tokens / s throughput on 1xB200 (130 tokens / s decoding per user)
|
|
747
|
+
|
|
748
|
+
<figure><img src="https://3215535692-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FxhOjnexMCB3dmuQFQ2Zq%2Fuploads%2FCJPJYh1uIS1yL8vskiOF%2Fimage.png?alt=media&token=f07aaad9-93bd-4507-836f-967a3d39b0e5" alt=""><figcaption></figcaption></figure>
|
|
749
|
+
|
|
750
|
+
And 13,000 tokens / s throughput on 1xB200 (still 130 token /s decoding per user)
|
|
751
|
+
|
|
752
|
+
<figure><img src="https://3215535692-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FxhOjnexMCB3dmuQFQ2Zq%2Fuploads%2FrXaHEknUb1QW1v0arO0q%2Fimage.png?alt=media&token=dd81b731-90bb-4d1b-a647-a64618f5952a" alt=""><figcaption></figcaption></figure>
|
|
753
|
+
|
|
754
|
+
### :hammer:Tool Calling with GLM-4.7-Flash
|
|
755
|
+
|
|
756
|
+
See [tool-calling-guide-for-local-llms](https://unsloth.ai/docs/basics/tool-calling-guide-for-local-llms "mention") for more details on how to do tool calling. In a new terminal (if using tmux, use CTRL+B+D), we create some tools like adding 2 numbers, executing Python code, executing Linux functions and much more:
|
|
757
|
+
|
|
758
|
+
{% code expandable="true" %}
|
|
759
|
+
|
|
760
|
+
```python
|
|
761
|
+
import json, subprocess, random
|
|
762
|
+
from typing import Any
|
|
763
|
+
def add_number(a: float | str, b: float | str) -> float:
|
|
764
|
+
return float(a) + float(b)
|
|
765
|
+
def multiply_number(a: float | str, b: float | str) -> float:
|
|
766
|
+
return float(a) * float(b)
|
|
767
|
+
def substract_number(a: float | str, b: float | str) -> float:
|
|
768
|
+
return float(a) - float(b)
|
|
769
|
+
def write_a_story() -> str:
|
|
770
|
+
return random.choice([
|
|
771
|
+
"A long time ago in a galaxy far far away...",
|
|
772
|
+
"There were 2 friends who loved sloths and code...",
|
|
773
|
+
"The world was ending because every sloth evolved to have superhuman intelligence...",
|
|
774
|
+
"Unbeknownst to one friend, the other accidentally coded a program to evolve sloths...",
|
|
775
|
+
])
|
|
776
|
+
def terminal(command: str) -> str:
|
|
777
|
+
if "rm" in command or "sudo" in command or "dd" in command or "chmod" in command:
|
|
778
|
+
msg = "Cannot execute 'rm, sudo, dd, chmod' commands since they are dangerous"
|
|
779
|
+
print(msg); return msg
|
|
780
|
+
print(f"Executing terminal command `{command}`")
|
|
781
|
+
try:
|
|
782
|
+
return str(subprocess.run(command, capture_output = True, text = True, shell = True, check = True).stdout)
|
|
783
|
+
except subprocess.CalledProcessError as e:
|
|
784
|
+
return f"Command failed: {e.stderr}"
|
|
785
|
+
def python(code: str) -> str:
|
|
786
|
+
data = {}
|
|
787
|
+
exec(code, data)
|
|
788
|
+
del data["__builtins__"]
|
|
789
|
+
return str(data)
|
|
790
|
+
MAP_FN = {
|
|
791
|
+
"add_number": add_number,
|
|
792
|
+
"multiply_number": multiply_number,
|
|
793
|
+
"substract_number": substract_number,
|
|
794
|
+
"write_a_story": write_a_story,
|
|
795
|
+
"terminal": terminal,
|
|
796
|
+
"python": python,
|
|
797
|
+
}
|
|
798
|
+
tools = [
|
|
799
|
+
{
|
|
800
|
+
"type": "function",
|
|
801
|
+
"function": {
|
|
802
|
+
"name": "add_number",
|
|
803
|
+
"description": "Add two numbers.",
|
|
804
|
+
"parameters": {
|
|
805
|
+
"type": "object",
|
|
806
|
+
"properties": {
|
|
807
|
+
"a": {
|
|
808
|
+
"type": "string",
|
|
809
|
+
"description": "The first number.",
|
|
810
|
+
},
|
|
811
|
+
"b": {
|
|
812
|
+
"type": "string",
|
|
813
|
+
"description": "The second number.",
|
|
814
|
+
},
|
|
815
|
+
},
|
|
816
|
+
"required": ["a", "b"],
|
|
817
|
+
},
|
|
818
|
+
},
|
|
819
|
+
},
|
|
820
|
+
{
|
|
821
|
+
"type": "function",
|
|
822
|
+
"function": {
|
|
823
|
+
"name": "multiply_number",
|
|
824
|
+
"description": "Multiply two numbers.",
|
|
825
|
+
"parameters": {
|
|
826
|
+
"type": "object",
|
|
827
|
+
"properties": {
|
|
828
|
+
"a": {
|
|
829
|
+
"type": "string",
|
|
830
|
+
"description": "The first number.",
|
|
831
|
+
},
|
|
832
|
+
"b": {
|
|
833
|
+
"type": "string",
|
|
834
|
+
"description": "The second number.",
|
|
835
|
+
},
|
|
836
|
+
},
|
|
837
|
+
"required": ["a", "b"],
|
|
838
|
+
},
|
|
839
|
+
},
|
|
840
|
+
},
|
|
841
|
+
{
|
|
842
|
+
"type": "function",
|
|
843
|
+
"function": {
|
|
844
|
+
"name": "substract_number",
|
|
845
|
+
"description": "Substract two numbers.",
|
|
846
|
+
"parameters": {
|
|
847
|
+
"type": "object",
|
|
848
|
+
"properties": {
|
|
849
|
+
"a": {
|
|
850
|
+
"type": "string",
|
|
851
|
+
"description": "The first number.",
|
|
852
|
+
},
|
|
853
|
+
"b": {
|
|
854
|
+
"type": "string",
|
|
855
|
+
"description": "The second number.",
|
|
856
|
+
},
|
|
857
|
+
},
|
|
858
|
+
"required": ["a", "b"],
|
|
859
|
+
},
|
|
860
|
+
},
|
|
861
|
+
},
|
|
862
|
+
{
|
|
863
|
+
"type": "function",
|
|
864
|
+
"function": {
|
|
865
|
+
"name": "write_a_story",
|
|
866
|
+
"description": "Writes a random story.",
|
|
867
|
+
"parameters": {
|
|
868
|
+
"type": "object",
|
|
869
|
+
"properties": {},
|
|
870
|
+
"required": [],
|
|
871
|
+
},
|
|
872
|
+
},
|
|
873
|
+
},
|
|
874
|
+
{
|
|
875
|
+
"type": "function",
|
|
876
|
+
"function": {
|
|
877
|
+
"name": "terminal",
|
|
878
|
+
"description": "Perform operations from the terminal.",
|
|
879
|
+
"parameters": {
|
|
880
|
+
"type": "object",
|
|
881
|
+
"properties": {
|
|
882
|
+
"command": {
|
|
883
|
+
"type": "string",
|
|
884
|
+
"description": "The command you wish to launch, e.g `ls`, `rm`, ...",
|
|
885
|
+
},
|
|
886
|
+
},
|
|
887
|
+
"required": ["command"],
|
|
888
|
+
},
|
|
889
|
+
},
|
|
890
|
+
},
|
|
891
|
+
{
|
|
892
|
+
"type": "function",
|
|
893
|
+
"function": {
|
|
894
|
+
"name": "python",
|
|
895
|
+
"description": "Call a Python interpreter with some Python code that will be ran.",
|
|
896
|
+
"parameters": {
|
|
897
|
+
"type": "object",
|
|
898
|
+
"properties": {
|
|
899
|
+
"code": {
|
|
900
|
+
"type": "string",
|
|
901
|
+
"description": "The Python code to run",
|
|
902
|
+
},
|
|
903
|
+
},
|
|
904
|
+
"required": ["code"],
|
|
905
|
+
},
|
|
906
|
+
},
|
|
907
|
+
},
|
|
908
|
+
]
|
|
909
|
+
```
|
|
910
|
+
|
|
911
|
+
{% endcode %}
|
|
912
|
+
|
|
913
|
+
We then use the below functions (copy and paste and execute) which will parse the function calls automatically and call the OpenAI endpoint for any model:
|
|
914
|
+
|
|
915
|
+
{% code overflow="wrap" expandable="true" %}
|
|
916
|
+
|
|
917
|
+
```python
|
|
918
|
+
from openai import OpenAI
|
|
919
|
+
def unsloth_inference(
|
|
920
|
+
messages,
|
|
921
|
+
temperature = 0.7,
|
|
922
|
+
top_p = 1.0,
|
|
923
|
+
top_k = -1,
|
|
924
|
+
repetition_penalty = 0.0,
|
|
925
|
+
):
|
|
926
|
+
messages = messages.copy()
|
|
927
|
+
openai_client = OpenAI(
|
|
928
|
+
base_url = "http://127.0.0.1:8001/v1",
|
|
929
|
+
api_key = "sk-no-key-required",
|
|
930
|
+
)
|
|
931
|
+
model_name = next(iter(openai_client.models.list())).id
|
|
932
|
+
print(f"Using model = {model_name}")
|
|
933
|
+
has_tool_calls = True
|
|
934
|
+
original_messages_len = len(messages)
|
|
935
|
+
while has_tool_calls:
|
|
936
|
+
print(f"Current messages = {messages}")
|
|
937
|
+
response = openai_client.chat.completions.create(
|
|
938
|
+
model = model_name,
|
|
939
|
+
messages = messages,
|
|
940
|
+
temperature = temperature,
|
|
941
|
+
top_p = top_p,
|
|
942
|
+
tools = tools if tools else None,
|
|
943
|
+
tool_choice = "auto" if tools else None,
|
|
944
|
+
extra_body = {"top_k": top_k, "min_p": min_p, "dry_multiplier" :repetition_penalty,}
|
|
945
|
+
)
|
|
946
|
+
tool_calls = response.choices[0].message.tool_calls or []
|
|
947
|
+
content = response.choices[0].message.content or ""
|
|
948
|
+
tool_calls_dict = [tc.to_dict() for tc in tool_calls] if tool_calls else tool_calls
|
|
949
|
+
messages.append({"role": "assistant", "tool_calls": tool_calls_dict, "content": content,})
|
|
950
|
+
for tool_call in tool_calls:
|
|
951
|
+
fx, args, _id = tool_call.function.name, tool_call.function.arguments, tool_call.id
|
|
952
|
+
out = MAP_FN[fx](**json.loads(args))
|
|
953
|
+
messages.append({"role": "tool", "tool_call_id": _id, "name": fx, "content": str(out),})
|
|
954
|
+
else:
|
|
955
|
+
has_tool_calls = False
|
|
956
|
+
return messages
|
|
957
|
+
```
|
|
958
|
+
|
|
959
|
+
{% endcode %}
|
|
960
|
+
|
|
961
|
+
After launching GLM-4.7-Flash via `llama-server` like in [#deploy-with-llama-server-and-openais-completion-library](#deploy-with-llama-server-and-openais-completion-library "mention") or see [tool-calling-guide-for-local-llms](https://unsloth.ai/docs/basics/tool-calling-guide-for-local-llms "mention") for more details, we then can do some tool calls:
|
|
962
|
+
|
|
963
|
+
**Tool Call for mathematical operations for GLM 4.7**
|
|
964
|
+
|
|
965
|
+
{% code overflow="wrap" %}
|
|
966
|
+
|
|
967
|
+
```python
|
|
968
|
+
messages = [{
|
|
969
|
+
"role": "user",
|
|
970
|
+
"content": [{"type": "text", "text": "What is today's date plus 3 days?"}],
|
|
971
|
+
}]
|
|
972
|
+
unsloth_inference(messages, temperature = 1.0, top_p = 0.95, top_k = -1, min_p = 0.01)
|
|
973
|
+
```
|
|
974
|
+
|
|
975
|
+
{% endcode %}
|
|
976
|
+
|
|
977
|
+
<figure><img src="https://3215535692-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FxhOjnexMCB3dmuQFQ2Zq%2Fuploads%2FoFkZ20QOSGdzT4iz2SOB%2Fimage.png?alt=media&token=e4ca30b0-dcec-4a26-b019-dd33f0600949" alt=""><figcaption></figcaption></figure>
|
|
978
|
+
|
|
979
|
+
**Tool Call to execute generated Python code for GLM-4.7-Flash**
|
|
980
|
+
|
|
981
|
+
{% code overflow="wrap" %}
|
|
982
|
+
|
|
983
|
+
```python
|
|
984
|
+
messages = [{
|
|
985
|
+
"role": "user",
|
|
986
|
+
"content": [{"type": "text", "text": "Create a Fibonacci function in Python and find fib(20)."}],
|
|
987
|
+
}]
|
|
988
|
+
unsloth_inference(messages, temperature = 1.0, top_p = 0.95, top_k = -1, min_p = 0.01)
|
|
989
|
+
```
|
|
990
|
+
|
|
991
|
+
{% endcode %}
|
|
992
|
+
|
|
993
|
+
<figure><img src="https://3215535692-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FxhOjnexMCB3dmuQFQ2Zq%2Fuploads%2FhS8sWtZwjwerElezCc2C%2Fimage.png?alt=media&token=39032ef8-386e-4837-8dd2-c552c80a3ee3" alt="" width="563"><figcaption></figcaption></figure>
|
|
994
|
+
|
|
995
|
+
### Benchmarks
|
|
996
|
+
|
|
997
|
+
GLM-4.7-Flash is the best performing 30B model across all benchmarks except AIME 25.
|