text stringlengths 5 631k | id stringlengths 14 178 | metadata dict | __index_level_0__ int64 0 647 |
|---|---|---|---|
# Copyright 2022 HuggingFace Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writ... | transformers/tests/models/markuplm/test_feature_extraction_markuplm.py/0 | {
"file_path": "transformers/tests/models/markuplm/test_feature_extraction_markuplm.py",
"repo_id": "transformers",
"token_count": 1471
} | 560 |
# Copyright 2020 The HuggingFace Team. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicabl... | transformers/tests/models/mobilebert/test_modeling_mobilebert.py/0 | {
"file_path": "transformers/tests/models/mobilebert/test_modeling_mobilebert.py",
"repo_id": "transformers",
"token_count": 7780
} | 561 |
# Copyright 2020 The HuggingFace Team. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicabl... | transformers/tests/models/modernbert_decoder/test_modeling_modernbert_decoder.py/0 | {
"file_path": "transformers/tests/models/modernbert_decoder/test_modeling_modernbert_decoder.py",
"repo_id": "transformers",
"token_count": 3618
} | 562 |
# Copyright 2021, The HuggingFace Inc. team. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by app... | transformers/tests/models/musicgen/test_modeling_musicgen.py/0 | {
"file_path": "transformers/tests/models/musicgen/test_modeling_musicgen.py",
"repo_id": "transformers",
"token_count": 31037
} | 563 |
# Copyright 2022 HuggingFace Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writ... | transformers/tests/models/oneformer/test_image_processing_oneformer.py/0 | {
"file_path": "transformers/tests/models/oneformer/test_image_processing_oneformer.py",
"repo_id": "transformers",
"token_count": 8875
} | 564 |
# Copyright 2024 Microsoft and the HuggingFace Inc. team. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless re... | transformers/tests/models/phi3/test_modeling_phi3.py/0 | {
"file_path": "transformers/tests/models/phi3/test_modeling_phi3.py",
"repo_id": "transformers",
"token_count": 9656
} | 565 |
# Copyright 2024 The HuggingFace Team. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicabl... | transformers/tests/models/pixtral/test_processing_pixtral.py/0 | {
"file_path": "transformers/tests/models/pixtral/test_processing_pixtral.py",
"repo_id": "transformers",
"token_count": 5838
} | 566 |
# Copyright 2020 The HuggingFace Inc. team, The Microsoft Research team.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required... | transformers/tests/models/prophetnet/test_modeling_prophetnet.py/0 | {
"file_path": "transformers/tests/models/prophetnet/test_modeling_prophetnet.py",
"repo_id": "transformers",
"token_count": 25603
} | 567 |
# Copyright 2020 The HuggingFace Team. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicabl... | transformers/tests/models/rag/test_retrieval_rag.py/0 | {
"file_path": "transformers/tests/models/rag/test_retrieval_rag.py",
"repo_id": "transformers",
"token_count": 6761
} | 568 |
# Copyright 2023 The HuggingFace Team. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicabl... | transformers/tests/models/rwkv/test_modeling_rwkv.py/0 | {
"file_path": "transformers/tests/models/rwkv/test_modeling_rwkv.py",
"repo_id": "transformers",
"token_count": 8154
} | 569 |
# Copyright 2023 HuggingFace Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writ... | transformers/tests/models/seamless_m4t/test_feature_extraction_seamless_m4t.py/0 | {
"file_path": "transformers/tests/models/seamless_m4t/test_feature_extraction_seamless_m4t.py",
"repo_id": "transformers",
"token_count": 7167
} | 570 |
# Copyright 2025 The HuggingFace Inc. team. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by appl... | transformers/tests/models/smolvlm/test_modeling_smolvlm.py/0 | {
"file_path": "transformers/tests/models/smolvlm/test_modeling_smolvlm.py",
"repo_id": "transformers",
"token_count": 13567
} | 571 |
# Copyright 2021 The HuggingFace Inc. team. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by appl... | transformers/tests/models/splinter/test_modeling_splinter.py/0 | {
"file_path": "transformers/tests/models/splinter/test_modeling_splinter.py",
"repo_id": "transformers",
"token_count": 9810
} | 572 |
# Copyright 2023 The HuggingFace Inc. team. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by appl... | transformers/tests/models/swiftformer/test_modeling_swiftformer.py/0 | {
"file_path": "transformers/tests/models/swiftformer/test_modeling_swiftformer.py",
"repo_id": "transformers",
"token_count": 4504
} | 573 |
# Copyright 2024 HuggingFace Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writ... | transformers/tests/models/timm_wrapper/test_image_processing_timm_wrapper.py/0 | {
"file_path": "transformers/tests/models/timm_wrapper/test_image_processing_timm_wrapper.py",
"repo_id": "transformers",
"token_count": 1470
} | 574 |
# Copyright 2021 HuggingFace Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writ... | transformers/tests/models/yolos/test_image_processing_yolos.py/0 | {
"file_path": "transformers/tests/models/yolos/test_image_processing_yolos.py",
"repo_id": "transformers",
"token_count": 14287
} | 575 |
# Copyright 2020 The HuggingFace Team. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicabl... | transformers/tests/pipelines/test_pipelines_table_question_answering.py/0 | {
"file_path": "transformers/tests/pipelines/test_pipelines_table_question_answering.py",
"repo_id": "transformers",
"token_count": 7888
} | 576 |
# Copyright 2023 The HuggingFace Team. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicabl... | transformers/tests/quantization/autoawq/test_awq.py/0 | {
"file_path": "transformers/tests/quantization/autoawq/test_awq.py",
"repo_id": "transformers",
"token_count": 9308
} | 577 |
# Copyright 2025 Advanced Micro Devices, Inc. and The HuggingFace Inc. team. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENS... | transformers/tests/quantization/quark_integration/test_quark.py/0 | {
"file_path": "transformers/tests/quantization/quark_integration/test_quark.py",
"repo_id": "transformers",
"token_count": 2324
} | 578 |
import json
import logging
import os
import subprocess
from argparse import ArgumentParser
logger = logging.getLogger(__name__)
def parse_args():
parser = ArgumentParser()
parsed, unknown = parser.parse_known_args()
for arg in unknown:
if arg.startswith(("-", "--")):
parser.add_argum... | transformers/tests/sagemaker/scripts/pytorch/run_ddp.py/0 | {
"file_path": "transformers/tests/sagemaker/scripts/pytorch/run_ddp.py",
"repo_id": "transformers",
"token_count": 694
} | 579 |
# Copyright 2024 The HuggingFace Inc. team. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by appl... | transformers/tests/test_processing_common.py/0 | {
"file_path": "transformers/tests/test_processing_common.py",
"repo_id": "transformers",
"token_count": 25244
} | 580 |
# Copyright 2024 The HuggingFace Team. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicabl... | transformers/tests/trainer/test_trainer_fsdp.py/0 | {
"file_path": "transformers/tests/trainer/test_trainer_fsdp.py",
"repo_id": "transformers",
"token_count": 3184
} | 581 |
# Copyright 2023 HuggingFace Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writ... | transformers/tests/utils/test_cache_utils.py/0 | {
"file_path": "transformers/tests/utils/test_cache_utils.py",
"repo_id": "transformers",
"token_count": 26311
} | 582 |
import os
import unittest
from pathlib import Path
from typing import Callable
import pytest
from transformers.utils.import_utils import (
Backend,
VersionComparison,
define_import_structure,
spread_import_structure,
)
import_structures = Path(__file__).parent / "import_structures"
def fetch__all_... | transformers/tests/utils/test_import_structure.py/0 | {
"file_path": "transformers/tests/utils/test_import_structure.py",
"repo_id": "transformers",
"token_count": 4929
} | 583 |
# coding=utf-8
# Copyright 2023 The HuggingFace Inc. team.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable... | transformers/utils/add_pipeline_model_mapping_to_test.py/0 | {
"file_path": "transformers/utils/add_pipeline_model_mapping_to_test.py",
"repo_id": "transformers",
"token_count": 5407
} | 584 |
# coding=utf-8
# Copyright 2020 The HuggingFace Inc. team.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable... | transformers/utils/check_tf_ops.py/0 | {
"file_path": "transformers/utils/check_tf_ops.py",
"repo_id": "transformers",
"token_count": 1302
} | 585 |
# Copyright 2025 The HuggingFace Team. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicabl... | transformers/utils/get_runner_map.py/0 | {
"file_path": "transformers/utils/get_runner_map.py",
"repo_id": "transformers",
"token_count": 858
} | 586 |
# coding=utf-8
# Copyright 2025 the HuggingFace Inc. team. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless r... | transformers/utils/scan_skipped_tests.py/0 | {
"file_path": "transformers/utils/scan_skipped_tests.py",
"repo_id": "transformers",
"token_count": 3188
} | 587 |
# coding=utf-8
# Copyright 2021 The HuggingFace Inc. team.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable... | transformers/utils/tests_fetcher.py/0 | {
"file_path": "transformers/utils/tests_fetcher.py",
"repo_id": "transformers",
"token_count": 21690
} | 588 |
# BCO Trainer
[](https://huggingface.co/models?other=bco,trl)
TRL supports the Binary Classifier Optimization (BCO).
The [BCO](https://huggingface.co/papers/2404.04656) authors train a binary classifier whose logit serves as a reward so that the classifier maps {pr... | trl/docs/source/bco_trainer.md/0 | {
"file_path": "trl/docs/source/bco_trainer.md",
"repo_id": "trl",
"token_count": 1246
} | 589 |
# Paper Index
<Tip warning={true}>
Section under construction. Feel free to contribute!
</Tip>
## Group Sequence Policy Optimization
**📜 Paper**: https://huggingface.co/papers/2507.18071
GSPO is a GRPO variant that computes importance sampling weights at the sequence level instead of per-token. To reproduce the ... | trl/docs/source/paper_index.md/0 | {
"file_path": "trl/docs/source/paper_index.md",
"repo_id": "trl",
"token_count": 2109
} | 590 |
# vLLM Integration
This document will guide you through the process of using vLLM with TRL for faster generation in online methods like GRPO and Online DPO. We first summarize a tl;dr on how to use vLLM with TRL, and then we will go into the details of how it works under the hood. Let's go! 🔥
## 🚀 How can I use vLL... | trl/docs/source/vllm_integration.md/0 | {
"file_path": "trl/docs/source/vllm_integration.md",
"repo_id": "trl",
"token_count": 4407
} | 591 |
# Copyright 2020-2025 The HuggingFace Team. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by appl... | trl/examples/datasets/prm800k.py/0 | {
"file_path": "trl/examples/datasets/prm800k.py",
"repo_id": "trl",
"token_count": 2257
} | 592 |
# RLHF pipeline for the creation of StackLLaMa: a Stack exchange llama-7b model.
There were three main steps to the training process:
1. Supervised fine-tuning of the base llama-7b model to create llama-7b-se:
- `torchrun --nnodes 1 --nproc_per_node 8 examples/research_projects/stack_llama/scripts/supervised_finet... | trl/examples/research_projects/stack_llama/scripts/README.md/0 | {
"file_path": "trl/examples/research_projects/stack_llama/scripts/README.md",
"repo_id": "trl",
"token_count": 696
} | 593 |
# Copyright 2020-2025 The HuggingFace Team. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by appl... | trl/examples/scripts/rloo/rloo.py/0 | {
"file_path": "trl/examples/scripts/rloo/rloo.py",
"repo_id": "trl",
"token_count": 2052
} | 594 |
# Copyright 2020-2025 The HuggingFace Team. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by appl... | trl/tests/test_best_of_n_sampler.py/0 | {
"file_path": "trl/tests/test_best_of_n_sampler.py",
"repo_id": "trl",
"token_count": 1685
} | 595 |
# Copyright 2020-2025 The HuggingFace Team. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by appl... | trl/tests/test_modeling_geometric_mixture_wrapper.py/0 | {
"file_path": "trl/tests/test_modeling_geometric_mixture_wrapper.py",
"repo_id": "trl",
"token_count": 1115
} | 596 |
# Copyright 2020-2025 The HuggingFace Team. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by appl... | trl/tests/test_xpo_trainer.py/0 | {
"file_path": "trl/tests/test_xpo_trainer.py",
"repo_id": "trl",
"token_count": 3738
} | 597 |
# Copyright 2020-2025 The HuggingFace Team. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by appl... | trl/trl/extras/dataset_formatting.py/0 | {
"file_path": "trl/trl/extras/dataset_formatting.py",
"repo_id": "trl",
"token_count": 1783
} | 598 |
# Copyright 2020-2025 The HuggingFace Team. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by appl... | trl/trl/rewards/other_rewards.py/0 | {
"file_path": "trl/trl/rewards/other_rewards.py",
"repo_id": "trl",
"token_count": 1001
} | 599 |
# Copyright 2020-2025 The HuggingFace Team. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by appl... | trl/trl/trainer/cpo_config.py/0 | {
"file_path": "trl/trl/trainer/cpo_config.py",
"repo_id": "trl",
"token_count": 4048
} | 600 |
# Copyright 2020-2025 The HuggingFace Team. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by appl... | trl/trl/trainer/nash_md_config.py/0 | {
"file_path": "trl/trl/trainer/nash_md_config.py",
"repo_id": "trl",
"token_count": 624
} | 601 |
# Copyright 2020-2025 The HuggingFace Team. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by appl... | trl/trl/trainer/utils.py/0 | {
"file_path": "trl/trl/trainer/utils.py",
"repo_id": "trl",
"token_count": 27524
} | 602 |
import json
from pathlib import Path
from datasets import Dataset
from huggingface_hub import HfApi
ORG_NAME = "agents-course"
def main():
"""Push quiz questions to the Hugging Face Hub"""
for file in Path("data").glob("*.json"):
print(f"Processing {file}")
with open(file, "r") as f:
... | agents-course/quiz/push_questions.py/0 | {
"file_path": "agents-course/quiz/push_questions.py",
"repo_id": "agents-course",
"token_count": 319
} | 0 |
# Conclusion
If you've made it this far, congratulations! 🥳 You've successfully built your very own Pokémon battle agent! ⚔️🎮
You’ve conquered the fundamentals of **Agentic workflows**, connected an **LLM** to a game environment, and deployed an intelligent Agent ready to face the challenges of battle.
But the jou... | agents-course/units/en/bonus-unit3/conclusion.mdx/0 | {
"file_path": "agents-course/units/en/bonus-unit3/conclusion.mdx",
"repo_id": "agents-course",
"token_count": 280
} | 1 |
# Messages and Special Tokens
Now that we understand how LLMs work, let's look at **how they structure their generations through chat templates**.
Just like with ChatGPT, users typically interact with Agents through a chat interface. Therefore, we aim to understand how LLMs manage chats.
> **Q**: But ... When, I'm i... | agents-course/units/en/unit1/messages-and-special-tokens.mdx/0 | {
"file_path": "agents-course/units/en/unit1/messages-and-special-tokens.mdx",
"repo_id": "agents-course",
"token_count": 3020
} | 2 |
# What is `LangGraph`?
`LangGraph` is a framework developed by [LangChain](https://www.langchain.com/) **to manage the control flow of applications that integrate an LLM**.
## Is `LangGraph` different from `LangChain`?
LangChain provides a standard interface to interact with models and other components, useful for r... | agents-course/units/en/unit2/langgraph/when_to_use_langgraph.mdx/0 | {
"file_path": "agents-course/units/en/unit2/langgraph/when_to_use_langgraph.mdx",
"repo_id": "agents-course",
"token_count": 1021
} | 3 |
# Small Quiz (ungraded) [[quiz1]]
Let's test your understanding of `smolagents` with a quick quiz! Remember, testing yourself helps reinforce learning and identify areas that may need review.
This is an optional quiz and it's not graded.
### Q1: What is one of the primary advantages of choosing `smolagents` over oth... | agents-course/units/en/unit2/smolagents/quiz1.mdx/0 | {
"file_path": "agents-course/units/en/unit2/smolagents/quiz1.mdx",
"repo_id": "agents-course",
"token_count": 1572
} | 4 |
# Claim Your Certificate 🎓
If you scored **above 30%, congratulations! 👏 You're now eligible to claim your official certificate.**
Follow the steps below to receive it:
1. Visit the [certificate page](https://huggingface.co/spaces/agents-course/Unit4-Final-Certificate).
2. **Sign in** with your Hugging Face accoun... | agents-course/units/en/unit4/get-your-certificate.mdx/0 | {
"file_path": "agents-course/units/en/unit4/get-your-certificate.mdx",
"repo_id": "agents-course",
"token_count": 352
} | 5 |
# Introducción
<img src="https://huggingface.co/datasets/agents-course/course-images/resolve/main/en/bonus-unit3/pokemon_thumbnail.png" alt="Unidad Bonus 3 IA en Juegos"/>
🎶 ¡Quiero ser el mejor...! 🎶
¡Bienvenido a esta **unidad bonus**, donde explorarás la emocionante intersección entre los **Agentes de IA y los ... | agents-course/units/es/bonus-unit3/introduction.mdx/0 | {
"file_path": "agents-course/units/es/bonus-unit3/introduction.mdx",
"repo_id": "agents-course",
"token_count": 751
} | 6 |
### P1: ¿Qué es un Agente?
¿Cuál de las siguientes opciones describe mejor a un Agente de IA?
<Question
choices={[
{
text: "Un modelo de IA que puede razonar, planificar y usar herramientas para interactuar con su entorno para lograr un objetivo específico.",
explain: "Esta definición captura las características esenc... | agents-course/units/es/unit1/quiz1.mdx/0 | {
"file_path": "agents-course/units/es/unit1/quiz1.mdx",
"repo_id": "agents-course",
"token_count": 2808
} | 7 |
# Usando Agentes en LlamaIndex
¿Recuerdas a Alfred, nuestro agente mayordomo útil de antes? ¡Bueno, está a punto de recibir una mejora! Ahora que entendemos las herramientas disponibles en LlamaIndex, podemos darle a Alfred nuevas capacidades para servirnos mejor.
Pero antes de continuar, recordemos qué hace funciona... | agents-course/units/es/unit2/llama-index/agents.mdx/0 | {
"file_path": "agents-course/units/es/unit2/llama-index/agents.mdx",
"repo_id": "agents-course",
"token_count": 3092
} | 8 |
<CourseFloatingBanner chapter={2}
classNames="absolute z-10 right-0 top-0"
notebooks={[
{label: "Google Colab", value: "https://colab.research.google.com/#fileId=https://huggingface.co/agents-course/notebooks/blob/main/unit2/smolagents/retrieval_agents.ipynb"},
]} />
# Construyendo Sistemas RAG con Agentes
<T... | agents-course/units/es/unit2/smolagents/retrieval_agents.mdx/0 | {
"file_path": "agents-course/units/es/unit2/smolagents/retrieval_agents.mdx",
"repo_id": "agents-course",
"token_count": 3440
} | 9 |
# Práctica
Ahora que estás listo/a para profundizar en la creación de tu agente final, veamos cómo puedes enviarlo para su revisión.
## El Conjunto de Datos (Dataset)
El conjunto de datos utilizado en esta tabla de clasificación consta de 20 preguntas extraídas de las preguntas de nivel 1 del conjunto de **validació... | agents-course/units/es/unit4/hands-on.mdx/0 | {
"file_path": "agents-course/units/es/unit4/hands-on.mdx",
"repo_id": "agents-course",
"token_count": 1394
} | 10 |
# Lancer l'agent de combat Pokémon
Il est maintenant temps de combattre ! ⚡️
## **Combattez l'agent de Stream !**
Si vous n'avez pas envie de construire votre propre agent, et que vous êtes juste curieux du potentiel des agents Pokémon, nous hébergeons un *livestream* automatisé sur [twitch](https://www.twitch.tv/jo... | agents-course/units/fr/bonus-unit3/launching_agent_battle.mdx/0 | {
"file_path": "agents-course/units/fr/bonus-unit3/launching_agent_battle.mdx",
"repo_id": "agents-course",
"token_count": 1154
} | 11 |
# Quiz rapide 2 [[quiz2]]
Hein ?! Un autre quiz ? On sait, on sait, ... 😅 Mais ce court quiz non noté est là pour **vous aider à renforcer les concepts clés que vous venez d'apprendre**.
Ce quiz porte sur les LLM, les systèmes de messages et les outils ; des composants essentiels pour comprendre et construire des ag... | agents-course/units/fr/unit1/quiz2.mdx/0 | {
"file_path": "agents-course/units/fr/unit1/quiz2.mdx",
"repo_id": "agents-course",
"token_count": 1200
} | 12 |
# Que sont les *components* dans LlamaIndex ?
Vous vous souvenez d'Alfred, notre agent majordome serviable de l'Unité 1 ?
Pour nous aider efficacement, Alfred doit comprendre nos demandes et **préparer, trouver et utiliser les informations pertinentes pour aider à accomplir les tâches.**
C'est là que les *components* ... | agents-course/units/fr/unit2/llama-index/components.mdx/0 | {
"file_path": "agents-course/units/fr/unit2/llama-index/components.mdx",
"repo_id": "agents-course",
"token_count": 5075
} | 13 |
<CourseFloatingBanner
classNames="absolute z-10 right-0 top-0"
notebooks={[
{label: "Google Colab", value: "https://colab.research.google.com/#fileId=https://huggingface.co/agents-course/notebooks/blob/main/fr/unit2/smolagents/tool_calling_agents.ipynb"},
]}
askForHelpUrl="http://hf.co/join/discord" />
# Écri... | agents-course/units/fr/unit2/smolagents/tool_calling_agents.mdx/0 | {
"file_path": "agents-course/units/fr/unit2/smolagents/tool_calling_agents.mdx",
"repo_id": "agents-course",
"token_count": 1588
} | 14 |
# Qu'est-ce que GAIA ?
[GAIA](https://huggingface.co/papers/2311.12983) est un ***benchmark* conçu pour évaluer les assistants IA sur des tâches du monde réel** nécessitant une combinaison de capacités fondamentales comme le raisonnement, la compréhension multimodale, la navigation *web* et l'utilisation d'outils.
Il... | agents-course/units/fr/unit4/what-is-gaia.mdx/0 | {
"file_path": "agents-course/units/fr/unit4/what-is-gaia.mdx",
"repo_id": "agents-course",
"token_count": 1677
} | 15 |
# 사고: AI 에이전트의 내부 추론과 Re-Act 방식 [[thought-internal-reasoning-and-the-re-act-approach]]
<Tip>
이 섹션에서는 AI 에이전트의 내면—즉, 추론하고 계획하는 능력을 자세히 살펴봅니다. 에이전트가 내부 대화를 통해 정보를 분석하고, 복잡한 문제를 다루기 쉬운 단계로 나누며, 다음 행동을 결정하는 과정을 탐구합니다. 또한 'Re-Act' 방식이라는 프롬프팅 기법을 소개합니다. 이는 모델이 행동하기 전에 '단계적으로 생각'하도록 유도하는 방법입니다.
</Tip>
사고는 **에이전트가 작업을 해결하기... | agents-course/units/ko/unit1/thoughts.mdx/0 | {
"file_path": "agents-course/units/ko/unit1/thoughts.mdx",
"repo_id": "agents-course",
"token_count": 3661
} | 16 |
# Действия: Обеспечение взаимодействия Агента с его Окружением
<Tip>
В этом разделе мы рассмотрим конкретные действия AI агента по взаимодействию с окружением.
Мы расскажем о том, как представляются действия (с помощью JSON или кода), о важности подхода "остановить и разобрать", а также представим различные типы аге... | agents-course/units/ru-RU/unit1/actions.mdx/0 | {
"file_path": "agents-course/units/ru-RU/unit1/actions.mdx",
"repo_id": "agents-course",
"token_count": 6337
} | 17 |
- title: Chương 0. Welcome to the course
sections:
- local: unit0/introduction
title: Chào mừng bạn đến với khóa học 🤗
- local: unit0/onboarding
title: Làm quen
- local: unit0/discord101
title: (Bổ trợ) Discord 101 (Giới thiệu cơ bản về Discord)
- title: Live 1. Cách khóa học vận hành + Hỏi và Đáp
... | agents-course/units/vi/_toctree.yml/0 | {
"file_path": "agents-course/units/vi/_toctree.yml",
"repo_id": "agents-course",
"token_count": 1051
} | 18 |
# Tin nhắn và Token đặc biệt
Giờ ta đã hiểu cách LLM hoạt động, hãy cùng xem **cách chúng tổ chức các phản hồi thông qua chat templates**.
Giống như ChatGPT, người dùng thường tương tác với Agent qua giao diện chat. Do đó, ta cần hiểu cách LLM quản lý các cuộc hội thoại.
> **Hỏi**: Nhưng... Khi tôi dùng ChatGPT/Hugg... | agents-course/units/vi/unit1/messages-and-special-tokens.mdx/0 | {
"file_path": "agents-course/units/vi/unit1/messages-and-special-tokens.mdx",
"repo_id": "agents-course",
"token_count": 8304
} | 19 |
# 什么是函数调用?(What is Function Calling?)
函数调用是**大语言模型 (LLM) 对其环境采取行动的一种方式**。它最初在 [GPT-4中引入](https://openai.com/index/function-calling-and-other-api-updates/),然后被其他模型复制。
就像智能体 (Agent) 的工具一样,函数调用赋予了模型**对其环境采取行动的能力**。然而,函数调用能力是**由模型学习的**,并且**比其他智能体技术更少依赖提示**。
在第1单元中,智能体**没有学习使用工具 (Tools)**,我们只是提供了工具列表,并依赖模型**能够泛化使用这些工具定义计... | agents-course/units/zh-CN/bonus-unit1/what-is-function-calling.mdx/0 | {
"file_path": "agents-course/units/zh-CN/bonus-unit1/what-is-function-calling.mdx",
"repo_id": "agents-course",
"token_count": 2122
} | 20 |
# 智能体简介 (Introduction to Agents)
<img src="https://huggingface.co/datasets/agents-course/course-images/resolve/main/en/unit1/thumbnail.jpg" alt="Thumbnail"/>
欢迎来到第一单元,在这里**你将在 AI 智能体 (AI Agents) 的基础知识中建立坚实的基础**,包括:
* **理解智能体 (Understanding Agents)**
* 什么是智能体,它是如何工作的?
* 智能体如何使用推理 (Reasoning) 和规划 (Planning) 做出决策?... | agents-course/units/zh-CN/unit1/introduction.mdx/0 | {
"file_path": "agents-course/units/zh-CN/unit1/introduction.mdx",
"repo_id": "agents-course",
"token_count": 1135
} | 21 |
# 测试你对 LangGraph 的理解
让我们通过快速测验来测试你对 `LangGraph` 的理解!这将帮助你巩固目前学到的关键概念。
本测验为可选项目,不计入评分。
### Q1: LangGraph 的主要目的是什么?
哪个描述最能体现 LangGraph 的设计目标?
<Question
choices={[
{
text: "构建包含 LLM 应用的流程控制的框架",
explain: "正确!LangGraph 专门设计用于帮助构建和管理使用 LLM 应用的流程控制。",
correct: true
},
{
text: "提供与不同 LLM 模型交互接口的库",
... | agents-course/units/zh-CN/unit2/langgraph/quiz1.mdx/0 | {
"file_path": "agents-course/units/zh-CN/unit2/langgraph/quiz1.mdx",
"repo_id": "agents-course",
"token_count": 2542
} | 22 |
<CourseFloatingBanner chapter={2}
classNames="absolute z-10 right-0 top-0"
notebooks={[
{label: "Google Colab", value: "https://colab.research.google.com/#fileId=https://huggingface.co/agents-course/notebooks/blob/main/unit2/smolagents/multiagent_notebook.ipynb"},
]} />
# 多智能体系统
多智能体系统使**专业智能体能够在复杂任务上进行协作**,提... | agents-course/units/zh-CN/unit2/smolagents/multi_agent_systems.mdx/0 | {
"file_path": "agents-course/units/zh-CN/unit2/smolagents/multi_agent_systems.mdx",
"repo_id": "agents-course",
"token_count": 11626
} | 23 |
# 结论
**恭喜你完成Agent课程!**
经过不懈坚持和投入,你已经在AI智能体方面打下了坚实的基础。
但完成这个课程**并不是你旅程的终点**。这只是一个开始:不要在探索下一个章节方面犹豫,我们在那里分享了更多我们精选的资源,以帮助你继续学习,包括像**MCPs**等进阶资源。
**谢谢你**参与这个课程。**我们希望您喜欢这门课程,就像我们享受这个课程的编写那样**。
別忘了:**持续学习,保持卓越🤗** | agents-course/units/zh-CN/unit4/conclusion.mdx/0 | {
"file_path": "agents-course/units/zh-CN/unit4/conclusion.mdx",
"repo_id": "agents-course",
"token_count": 406
} | 24 |
.PHONY: clean-ptx clean test
clean-ptx:
find target -name "*.ptx" -type f -delete
echo "" > candle-kernels/src/lib.rs
touch candle-kernels/build.rs
touch candle-examples/build.rs
touch candle-flash-attn/build.rs
clean:
cargo clean
test:
cargo test
all: test
| candle/Makefile/0 | {
"file_path": "candle/Makefile",
"repo_id": "candle",
"token_count": 107
} | 25 |
# Writing a custom kernel
| candle/candle-book/src/cuda/writing.md/0 | {
"file_path": "candle/candle-book/src/cuda/writing.md",
"repo_id": "candle",
"token_count": 6
} | 26 |
# Tracing
Tracing is a powerful tool for identifying performance issues and bottlenecks in code.
> Profiling on GPUs is trickier due to asynchronous execution, see the [GPU section](#gpu).
## Overview
Candle uses the [tracing](https://docs.rs/tracing/latest/tracing/) crate for instrumentation.
To try it out, run a... | candle/candle-book/src/tracing.md/0 | {
"file_path": "candle/candle-book/src/tracing.md",
"repo_id": "candle",
"token_count": 862
} | 27 |
use crate::benchmarks::{BenchDevice, BenchDeviceHandler};
use candle_core::{DType, Device, Tensor};
use criterion::{black_box, criterion_group, Criterion, Throughput};
use std::time::Instant;
fn rand_uniform(a: &Tensor) {
a.rand_like(-1.0, 123.0).unwrap();
}
fn rand_normal(a: &Tensor) {
a.randn_like(100.0, 15... | candle/candle-core/benches/benchmarks/random.rs/0 | {
"file_path": "candle/candle-core/benches/benchmarks/random.rs",
"repo_id": "candle",
"token_count": 812
} | 28 |
//! Traits and methods for CPU-backed Tensors
pub mod erf;
pub mod kernels;
#[allow(unused)]
trait Cpu<const ARR: usize> {
type Unit;
type Array;
const STEP: usize;
const EPR: usize;
fn n() -> usize;
unsafe fn zero() -> Self::Unit;
unsafe fn zero_array() -> Self::Array;
unsafe fn load... | candle/candle-core/src/cpu/mod.rs/0 | {
"file_path": "candle/candle-core/src/cpu/mod.rs",
"repo_id": "candle",
"token_count": 3326
} | 29 |
//! Candle-specific Error and Result
use crate::{DType, DeviceLocation, Layout, MetalError, Shape};
#[derive(Debug, Clone)]
pub struct MatMulUnexpectedStriding {
pub lhs_l: Layout,
pub rhs_l: Layout,
pub bmnk: (usize, usize, usize, usize),
pub msg: &'static str,
}
impl std::fmt::Debug for Error {
... | candle/candle-core/src/error.rs/0 | {
"file_path": "candle/candle-core/src/error.rs",
"repo_id": "candle",
"token_count": 4127
} | 30 |
use super::utils::{
get_scale_min_k4, group_for_dequantization, group_for_quantization, make_q3_quants,
make_qkx1_quants, make_qx_quants, nearest_int,
};
use super::GgmlDType;
use crate::Result;
use byteorder::{ByteOrder, LittleEndian};
use half::{bf16, f16};
use rayon::prelude::*;
// Default to QK_K 256 rathe... | candle/candle-core/src/quantized/k_quants.rs/0 | {
"file_path": "candle/candle-core/src/quantized/k_quants.rs",
"repo_id": "candle",
"token_count": 43384
} | 31 |
//! Useful functions for checking features.
use std::str::FromStr;
pub fn get_num_threads() -> usize {
// Respond to the same environment variable as rayon.
match std::env::var("RAYON_NUM_THREADS")
.ok()
.and_then(|s| usize::from_str(&s).ok())
{
Some(x) if x > 0 => x,
Some(_... | candle/candle-core/src/utils.rs/0 | {
"file_path": "candle/candle-core/src/utils.rs",
"repo_id": "candle",
"token_count": 399
} | 32 |
use candle_core::{test_device, test_utils, DType, Device, IndexOp, Result, Tensor, D};
use float8::F8E4M3;
fn zeros(device: &Device) -> Result<()> {
let tensor = Tensor::zeros((5, 2), DType::F32, device)?;
let (dim1, dim2) = tensor.dims2()?;
assert_eq!(dim1, 5);
assert_eq!(dim2, 2);
Ok(())
}
fn on... | candle/candle-core/tests/tensor_tests.rs/0 | {
"file_path": "candle/candle-core/tests/tensor_tests.rs",
"repo_id": "candle",
"token_count": 37348
} | 33 |
[package]
name = "candle-examples"
version.workspace = true
edition.workspace = true
description.workspace = true
repository.workspace = true
keywords.workspace = true
categories.workspace = true
license.workspace = true
readme = "README.md"
[dependencies]
accelerate-src = { workspace = true, optional = true }
candle ... | candle/candle-examples/Cargo.toml/0 | {
"file_path": "candle/candle-examples/Cargo.toml",
"repo_id": "candle",
"token_count": 1497
} | 34 |
#[cfg(feature = "mkl")]
extern crate intel_mkl_src;
#[cfg(feature = "accelerate")]
extern crate accelerate_src;
use candle::{DType, Device, Tensor};
use candle_nn as nn;
use candle_transformers::models::chinese_clip::{ChineseClipConfig, ChineseClipModel};
use clap::Parser;
use tokenizers::Tokenizer;
#[derive(Parser)... | candle/candle-examples/examples/chinese_clip/main.rs/0 | {
"file_path": "candle/candle-examples/examples/chinese_clip/main.rs",
"repo_id": "candle",
"token_count": 3197
} | 35 |
#include <stdint.h>
#include "reduction_utils.cuh"
template <typename scalar_t>
__device__ void
rms_norm_kernel(scalar_t *__restrict__ out, // [num_tokens, hidden_size]
const scalar_t *__restrict__ input, // [num_tokens, hidden_size]
const float epsilon, const uint32_t num_token... | candle/candle-examples/examples/custom-ops/kernels/layernorm_kernels.cu/0 | {
"file_path": "candle/candle-examples/examples/custom-ops/kernels/layernorm_kernels.cu",
"repo_id": "candle",
"token_count": 561
} | 36 |
# candle-efficientnet
Demonstrates a Candle implementation of EfficientNet for image classification based on ImageNet classes.
## Running an example
```bash
$ cargo run --example efficientnet --release -- --image candle-examples/examples/yolo-v8/assets/bike.jpg --which b1
> bicycle-built-for-two, tandem bicycle, ta... | candle/candle-examples/examples/efficientnet/README.md/0 | {
"file_path": "candle/candle-examples/examples/efficientnet/README.md",
"repo_id": "candle",
"token_count": 171
} | 37 |
#[cfg(feature = "accelerate")]
extern crate accelerate_src;
#[cfg(feature = "mkl")]
extern crate intel_mkl_src;
use candle_transformers::models::{clip, flux, t5};
use anyhow::{Error as E, Result};
use candle::{IndexOp, Module, Tensor};
use candle_nn::VarBuilder;
use clap::Parser;
use tokenizers::Tokenizer;
#[derive... | candle/candle-examples/examples/flux/main.rs/0 | {
"file_path": "candle/candle-examples/examples/flux/main.rs",
"repo_id": "candle",
"token_count": 5445
} | 38 |
# candle-llama
Candle implementations of various Llama based architectures.
## Running an example
```bash
$ cargo run --example llama -- --prompt "Machine learning is " --which v32-3b-instruct
> Machine learning is the part of computer science which deals with the development of algorithms and
``` | candle/candle-examples/examples/llama/README.md/0 | {
"file_path": "candle/candle-examples/examples/llama/README.md",
"repo_id": "candle",
"token_count": 78
} | 39 |
# candle-marian-mt
`marian-mt` is a neural machine translation model. In this example it is used to
translate text from French to English. See the associated [model
card](https://huggingface.co/Helsinki-NLP/opus-mt-tc-big-fr-en) for details on
the model itself.
## Running an example
```bash
cargo run --example maria... | candle/candle-examples/examples/marian-mt/README.md/0 | {
"file_path": "candle/candle-examples/examples/marian-mt/README.md",
"repo_id": "candle",
"token_count": 471
} | 40 |
#[cfg(feature = "mkl")]
extern crate intel_mkl_src;
#[cfg(feature = "accelerate")]
extern crate accelerate_src;
use anyhow::Error as E;
use clap::{Parser, ValueEnum};
use candle::{DType, Device, Tensor};
use candle_nn::{ops::softmax, VarBuilder};
use candle_transformers::models::mobileclip;
use tokenizers::Tokenize... | candle/candle-examples/examples/mobileclip/main.rs/0 | {
"file_path": "candle/candle-examples/examples/mobileclip/main.rs",
"repo_id": "candle",
"token_count": 2389
} | 41 |
## Using ONNX models in Candle
This example demonstrates how to run [ONNX](https://github.com/onnx/onnx) based LLM models in Candle.
This script only implements SmolLM-135M right now.
You can run the examples with following commands:
```bash
cargo run --example onnx-llm --features onnx
``` | candle/candle-examples/examples/onnx-llm/README.md/0 | {
"file_path": "candle/candle-examples/examples/onnx-llm/README.md",
"repo_id": "candle",
"token_count": 94
} | 42 |
# candle-quantized-gemma
Candle implementation of quantized Gemma.
## Running an example
```bash
$ cargo run --example quantized-gemma -- --prompt "Write a function to calculate fibonacci numbers. "
> ```python
> def fibonacci(n):
> """Calculates the nth Fibonacci number using recursion."""
> if n <= 1:
> ... | candle/candle-examples/examples/quantized-gemma/README.md/0 | {
"file_path": "candle/candle-examples/examples/quantized-gemma/README.md",
"repo_id": "candle",
"token_count": 159
} | 43 |
#[cfg(feature = "mkl")]
extern crate intel_mkl_src;
#[cfg(feature = "accelerate")]
extern crate accelerate_src;
use anyhow::{Error as E, Result};
use clap::Parser;
use candle_transformers::models::quantized_recurrent_gemma::Model as QModel;
use candle_transformers::models::recurrent_gemma::{Config, Model as BModel};... | candle/candle-examples/examples/recurrent-gemma/main.rs/0 | {
"file_path": "candle/candle-examples/examples/recurrent-gemma/main.rs",
"repo_id": "candle",
"token_count": 4698
} | 44 |
## candle-rwkv
The [RWKV model](https://wiki.rwkv.com/) is a recurrent neural network model
with performance on par with transformer architectures. Several variants are
available, candle implements the v5 and v6 versions and can be used with
Eagle 7B([blog post](https://blog.rwkv.com/p/eagle-7b-soaring-past-transforme... | candle/candle-examples/examples/rwkv/README.md/0 | {
"file_path": "candle/candle-examples/examples/rwkv/README.md",
"repo_id": "candle",
"token_count": 235
} | 45 |
# candle-splade
SPLADE is a neural retrieval model which learns query/document sparse expansion via the BERT MLM head and sparse regularization. Sparse representations benefit from several advantages compared to dense approaches: efficient use of inverted index, explicit lexical match, interpretability... They also s... | candle/candle-examples/examples/splade/README.md/0 | {
"file_path": "candle/candle-examples/examples/splade/README.md",
"repo_id": "candle",
"token_count": 474
} | 46 |
#[cfg(feature = "mkl")]
extern crate intel_mkl_src;
#[cfg(feature = "accelerate")]
extern crate accelerate_src;
use std::path::Path;
use anyhow::{anyhow, Error as E, Result};
use clap::Parser;
use candle_transformers::models::stella_en_v5::{
Config, EmbedDim as StellaEmbedDim, EmbeddingModel,
};
use candle::{D... | candle/candle-examples/examples/stella-en-v5/main.rs/0 | {
"file_path": "candle/candle-examples/examples/stella-en-v5/main.rs",
"repo_id": "candle",
"token_count": 6512
} | 47 |
use std::path::PathBuf;
use anyhow::{Context, Error, Result};
use byteorder::{LittleEndian, ReadBytesExt};
use candle::{utils, DType, Device, Tensor};
use candle_nn::VarBuilder;
use candle_transformers::models::voxtral;
use candle_transformers::models::voxtral::{
VoxtralCache, VoxtralConfig, VoxtralEncoderConfig, ... | candle/candle-examples/examples/voxtral/model.rs/0 | {
"file_path": "candle/candle-examples/examples/voxtral/model.rs",
"repo_id": "candle",
"token_count": 6352
} | 48 |
/******************************************************************************
* Copyright (c) 2024, Tri Dao.
******************************************************************************/
#pragma once
#include <tuple>
#include <cstdio>
#if !defined(__CUDACC_RTC__)
#include "cuda_runtime.h"
#endif
#define CHECK... | candle/candle-flash-attn/kernels/hardware_info.h/0 | {
"file_path": "candle/candle-flash-attn/kernels/hardware_info.h",
"repo_id": "candle",
"token_count": 854
} | 49 |
fn main() {
println!("cargo:rerun-if-changed=build.rs");
println!("cargo:rerun-if-changed=src/compatibility.cuh");
println!("cargo:rerun-if-changed=src/cuda_utils.cuh");
println!("cargo:rerun-if-changed=src/binary_op_macros.cuh");
let builder = bindgen_cuda::Builder::default();
println!("cargo:... | candle/candle-kernels/build.rs/0 | {
"file_path": "candle/candle-kernels/build.rs",
"repo_id": "candle",
"token_count": 178
} | 50 |
#define _USE_MATH_DEFINES
#include<math.h>
#include<stdint.h>
#include "cuda_utils.cuh"
#define UNARY_OP(TYPENAME, FN_NAME, FUNC) \
extern "C" __global__ void FN_NAME( \
const size_t numel, \
const size_t num_dims, \
const size_t *info, \
const TYPENAME *inp, \
TYPENAME *out \
) { \
const size_... | candle/candle-kernels/src/unary.cu/0 | {
"file_path": "candle/candle-kernels/src/unary.cu",
"repo_id": "candle",
"token_count": 4820
} | 51 |
#include <metal_stdlib>
#include <metal_limits>
using namespace metal;
METAL_FUNC uint nonzero(uint n) {
return n == 0 ? 1 : n;
}
template<uint N>
constexpr uint nonzero() {
return N == 0 ? 1 : N;
}
template<typename T>
constexpr ushort granularity() {
return nonzero<vec_elements<T>::value>();
}
METAL_F... | candle/candle-metal-kernels/src/reduce.metal/0 | {
"file_path": "candle/candle-metal-kernels/src/reduce.metal",
"repo_id": "candle",
"token_count": 21447
} | 52 |
use crate::benchmarks::{BenchDevice, BenchDeviceHandler};
use candle::{DType, Device, Module, Tensor};
use candle_nn::{Conv2d, Conv2dConfig};
use criterion::{black_box, criterion_group, Criterion};
use std::time::Instant;
const B: usize = 1;
const C: usize = 1;
const M: usize = 128;
const K: usize = 128;
const K_SIZE:... | candle/candle-nn/benches/benchmarks/conv.rs/0 | {
"file_path": "candle/candle-nn/benches/benchmarks/conv.rs",
"repo_id": "candle",
"token_count": 808
} | 53 |
//! candle-nn
//!
//! ## Other Crates
//!
//! Candle consists of a number of crates. This crate holds structs and functions
//! that allow you to build and train neural nets. You may wish
//! to look at the docs for the other crates which can be found here:
//!
//! - [candle-core](https://docs.rs/candle-core/). Core Da... | candle/candle-nn/src/lib.rs/0 | {
"file_path": "candle/candle-nn/src/lib.rs",
"repo_id": "candle",
"token_count": 812
} | 54 |
use candle::{Result, Shape, Tensor};
use candle_nn::encoding::one_hot;
#[test]
fn test_i64_one_hot() -> Result<()> {
let device = candle::Device::Cpu;
let indices = Tensor::new(vec![vec![0i64, 2], vec![1, -1]], &device)?;
let depth = 4;
let on_value = 1.0;
let off_value = 0.0;
let one_hot = ... | candle/candle-nn/tests/one_hot.rs/0 | {
"file_path": "candle/candle-nn/tests/one_hot.rs",
"repo_id": "candle",
"token_count": 1592
} | 55 |
from typing import Union, Sequence
class Tensor:
"""
This contains the type hints for the magic methodes of the `candle.Tensor` class.
"""
def __add__(self, rhs: Union["Tensor", "Scalar"]) -> "Tensor":
"""
Add a scalar to a tensor or two tensors together.
"""
pass
... | candle/candle-pyo3/_additional_typing/__init__.py/0 | {
"file_path": "candle/candle-pyo3/_additional_typing/__init__.py",
"repo_id": "candle",
"token_count": 1174
} | 56 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.