text stringlengths 5 631k | id stringlengths 14 178 | metadata dict | __index_level_0__ int64 0 647 |
|---|---|---|---|
# coding=utf-8
# Copyright 2025 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 ag... | transformers/tests/models/deepseek_vl/test_modeling_deepseek_vl.py/0 | {
"file_path": "transformers/tests/models/deepseek_vl/test_modeling_deepseek_vl.py",
"repo_id": "transformers",
"token_count": 6685
} | 557 |
# 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/depth_pro/test_modeling_depth_pro.py/0 | {
"file_path": "transformers/tests/models/depth_pro/test_modeling_depth_pro.py",
"repo_id": "transformers",
"token_count": 7562
} | 558 |
# 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/models/dinov2_with_registers/test_modeling_dinov2_with_registers.py/0 | {
"file_path": "transformers/tests/models/dinov2_with_registers/test_modeling_dinov2_with_registers.py",
"repo_id": "transformers",
"token_count": 6228
} | 559 |
# 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/donut/test_processing_donut.py/0 | {
"file_path": "transformers/tests/models/donut/test_processing_donut.py",
"repo_id": "transformers",
"token_count": 930
} | 560 |
# 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/efficientnet/test_modeling_efficientnet.py/0 | {
"file_path": "transformers/tests/models/efficientnet/test_modeling_efficientnet.py",
"repo_id": "transformers",
"token_count": 3901
} | 561 |
# 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/tests/models/florence2/test_processing_florence2.py/0 | {
"file_path": "transformers/tests/models/florence2/test_processing_florence2.py",
"repo_id": "transformers",
"token_count": 5334
} | 562 |
# 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/models/gpt_oss/test_modeling_gpt_oss.py/0 | {
"file_path": "transformers/tests/models/gpt_oss/test_modeling_gpt_oss.py",
"repo_id": "transformers",
"token_count": 11486
} | 563 |
# 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/models/idefics3/test_modeling_idefics3.py/0 | {
"file_path": "transformers/tests/models/idefics3/test_modeling_idefics3.py",
"repo_id": "transformers",
"token_count": 10963
} | 564 |
# coding=utf-8
# 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 ag... | transformers/tests/models/kosmos2_5/test_image_processing_kosmos2_5.py/0 | {
"file_path": "transformers/tests/models/kosmos2_5/test_image_processing_kosmos2_5.py",
"repo_id": "transformers",
"token_count": 8071
} | 565 |
# 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/models/llava_next/test_modeling_llava_next.py/0 | {
"file_path": "transformers/tests/models/llava_next/test_modeling_llava_next.py",
"repo_id": "transformers",
"token_count": 10134
} | 566 |
# Copyright 2023 Mistral AI 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 r... | transformers/tests/models/mistral/test_modeling_mistral.py/0 | {
"file_path": "transformers/tests/models/mistral/test_modeling_mistral.py",
"repo_id": "transformers",
"token_count": 10346
} | 567 |
import shutil
import tempfile
import unittest
from transformers import Owlv2Processor
from transformers.testing_utils import require_scipy
from ...test_processing_common import ProcessorTesterMixin
@require_scipy
class Owlv2ProcessorTest(ProcessorTesterMixin, unittest.TestCase):
processor_class = Owlv2Processor... | transformers/tests/models/owlv2/test_processing_owlv2.py/0 | {
"file_path": "transformers/tests/models/owlv2/test_processing_owlv2.py",
"repo_id": "transformers",
"token_count": 243
} | 568 |
# 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/models/pixtral/test_modeling_pixtral.py/0 | {
"file_path": "transformers/tests/models/pixtral/test_modeling_pixtral.py",
"repo_id": "transformers",
"token_count": 1864
} | 569 |
# Copyright 2020, The RAG Authors and 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 appl... | transformers/tests/models/rag/test_modeling_rag.py/0 | {
"file_path": "transformers/tests/models/rag/test_modeling_rag.py",
"repo_id": "transformers",
"token_count": 22724
} | 570 |
# 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/roberta/test_modeling_roberta.py/0 | {
"file_path": "transformers/tests/models/roberta/test_modeling_roberta.py",
"repo_id": "transformers",
"token_count": 11138
} | 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/sew/test_modeling_sew.py/0 | {
"file_path": "transformers/tests/models/sew/test_modeling_sew.py",
"repo_id": "transformers",
"token_count": 9711
} | 572 |
# 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/unispeech/test_modeling_unispeech.py/0 | {
"file_path": "transformers/tests/models/unispeech/test_modeling_unispeech.py",
"repo_id": "transformers",
"token_count": 10615
} | 573 |
# Copyright 2022 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/vilt/test_modeling_vilt.py/0 | {
"file_path": "transformers/tests/models/vilt/test_modeling_vilt.py",
"repo_id": "transformers",
"token_count": 12166
} | 574 |
# 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/vivit/test_modeling_vivit.py/0 | {
"file_path": "transformers/tests/models/vivit/test_modeling_vivit.py",
"repo_id": "transformers",
"token_count": 6496
} | 575 |
# Copyright 2021 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/wav2vec2_phoneme/test_tokenization_wav2vec2_phoneme.py/0 | {
"file_path": "transformers/tests/models/wav2vec2_phoneme/test_tokenization_wav2vec2_phoneme.py",
"repo_id": "transformers",
"token_count": 10074
} | 576 |
# Copyright 2021 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/xglm/test_tokenization_xglm.py/0 | {
"file_path": "transformers/tests/models/xglm/test_tokenization_xglm.py",
"repo_id": "transformers",
"token_count": 4240
} | 577 |
# Copyright 2021 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_audio_classification.py/0 | {
"file_path": "transformers/tests/pipelines/test_pipelines_audio_classification.py",
"repo_id": "transformers",
"token_count": 3940
} | 578 |
# 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_summarization.py/0 | {
"file_path": "transformers/tests/pipelines/test_pipelines_summarization.py",
"repo_id": "transformers",
"token_count": 3371
} | 579 |
# 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/quantization/fbgemm_fp8/test_fbgemm_fp8.py/0 | {
"file_path": "transformers/tests/quantization/fbgemm_fp8/test_fbgemm_fp8.py",
"repo_id": "transformers",
"token_count": 5006
} | 580 |
# 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/test_pipeline_mixin.py/0 | {
"file_path": "transformers/tests/test_pipeline_mixin.py",
"repo_id": "transformers",
"token_count": 16843
} | 581 |
import random
import numpy as np
import torch
import torch.distributed as dist
import torch.nn as nn
from torch.utils.data import Dataset
from transformers import (
HfArgumentParser,
Trainer,
TrainingArguments,
set_seed,
)
from transformers.testing_utils import (
TestCasePlus,
backend_device_c... | transformers/tests/trainer/test_trainer_distributed_worker_seed.py/0 | {
"file_path": "transformers/tests/trainer/test_trainer_distributed_worker_seed.py",
"repo_id": "transformers",
"token_count": 1110
} | 582 |
# 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/utils/test_backbone_utils.py/0 | {
"file_path": "transformers/tests/utils/test_backbone_utils.py",
"repo_id": "transformers",
"token_count": 5009
} | 583 |
# 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/utils/test_image_utils.py/0 | {
"file_path": "transformers/tests/utils/test_image_utils.py",
"repo_id": "transformers",
"token_count": 18510
} | 584 |
import argparse
import os
import re
import subprocess
from typing import Optional
from huggingface_hub import paper_info
ROOT = os.getcwd().split("utils")[0]
DOCS_PATH = os.path.join(ROOT, "docs/source/en/model_doc")
MODELS_PATH = os.path.join(ROOT, "src/transformers/models")
COPYRIGHT_DISCLAIMER = """<!--Copyright... | transformers/utils/add_dates.py/0 | {
"file_path": "transformers/utils/add_dates.py",
"repo_id": "transformers",
"token_count": 4475
} | 585 |
import argparse
import json
import subprocess
def get_runner_status(target_runners, token):
offline_runners = []
cmd = [
"curl",
"-H",
"Accept: application/vnd.github+json",
"-H",
f"Authorization: Bearer {token}",
"https://api.github.com/repos/huggingface/trans... | transformers/utils/check_self_hosted_runner.py/0 | {
"file_path": "transformers/utils/check_self_hosted_runner.py",
"repo_id": "transformers",
"token_count": 650
} | 586 |
import os
import zipfile
import requests
from get_ci_error_statistics import download_artifact, get_artifacts_links
def get_daily_ci_runs(token, num_runs=7, workflow_id=None):
"""Get the workflow runs of the scheduled (daily) CI.
This only selects the runs triggered by the `schedule` event on the `main` bra... | transformers/utils/get_previous_daily_ci.py/0 | {
"file_path": "transformers/utils/get_previous_daily_ci.py",
"repo_id": "transformers",
"token_count": 2512
} | 587 |
# coding=utf-8
# Copyright 2021 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 requir... | transformers/utils/release.py/0 | {
"file_path": "transformers/utils/release.py",
"repo_id": "transformers",
"token_count": 2975
} | 588 |
from transformers import LlavaOnevisionVideoProcessor
class CustomVideoProcessor(LlavaOnevisionVideoProcessor):
pass
| transformers/utils/test_module/custom_video_processing.py/0 | {
"file_path": "transformers/utils/test_module/custom_video_processing.py",
"repo_id": "transformers",
"token_count": 34
} | 589 |
# Aligning Text-to-Image Diffusion Models with Reward Backpropagation
[](https://huggingface.co/models?other=alignprop,trl)
## The why
If your reward function is differentiable, directly backpropagating gradients from the reward models to the diffusion model... | trl/docs/source/alignprop_trainer.md/0 | {
"file_path": "trl/docs/source/alignprop_trainer.md",
"repo_id": "trl",
"token_count": 1570
} | 590 |
# Other
## profiling_decorator
[[autodoc]] extras.profiling.profiling_decorator
## profiling_context
[[autodoc]] extras.profiling.profiling_context
| trl/docs/source/others.md/0 | {
"file_path": "trl/docs/source/others.md",
"repo_id": "trl",
"token_count": 51
} | 591 |
# Using LLaMA models with TRL
We've begun rolling out examples to use Meta's LLaMA models in `trl` (see [Meta's LLaMA release](https://ai.facebook.com/blog/large-language-model-llama-meta-ai/) for the original LLaMA model).
## Efficient training strategies
Even training the smallest LLaMA model requires an enormous ... | trl/docs/source/using_llama_models.md/0 | {
"file_path": "trl/docs/source/using_llama_models.md",
"repo_id": "trl",
"token_count": 2915
} | 592 |
# 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/math_shepherd.py/0 | {
"file_path": "trl/examples/datasets/math_shepherd.py",
"repo_id": "trl",
"token_count": 2327
} | 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/research_projects/layer_skip/scripts/layer_skip_sft.py/0 | {
"file_path": "trl/examples/research_projects/layer_skip/scripts/layer_skip_sft.py",
"repo_id": "trl",
"token_count": 1279
} | 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/examples/scripts/ddpo.py/0 | {
"file_path": "trl/examples/scripts/ddpo.py",
"repo_id": "trl",
"token_count": 3209
} | 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/examples/scripts/reward_modeling.py/0 | {
"file_path": "trl/examples/scripts/reward_modeling.py",
"repo_id": "trl",
"token_count": 1851
} | 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/scripts/generate_zen_dataset.py/0 | {
"file_path": "trl/scripts/generate_zen_dataset.py",
"repo_id": "trl",
"token_count": 15761
} | 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/tests/test_bco_trainer.py/0 | {
"file_path": "trl/tests/test_bco_trainer.py",
"repo_id": "trl",
"token_count": 7812
} | 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/tests/test_kto_trainer.py/0 | {
"file_path": "trl/tests/test_kto_trainer.py",
"repo_id": "trl",
"token_count": 8277
} | 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/tests/test_vllm_client_server.py/0 | {
"file_path": "trl/tests/test_vllm_client_server.py",
"repo_id": "trl",
"token_count": 6258
} | 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/extras/best_of_n_sampler.py/0 | {
"file_path": "trl/trl/extras/best_of_n_sampler.py",
"repo_id": "trl",
"token_count": 2439
} | 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/rewards/format_rewards.py/0 | {
"file_path": "trl/trl/rewards/format_rewards.py",
"repo_id": "trl",
"token_count": 744
} | 602 |
# 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/callbacks.py/0 | {
"file_path": "trl/trl/trainer/callbacks.py",
"repo_id": "trl",
"token_count": 13702
} | 603 |
# 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/model_config.py/0 | {
"file_path": "trl/trl/trainer/model_config.py",
"repo_id": "trl",
"token_count": 3494
} | 604 |
# 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/sft_trainer.py/0 | {
"file_path": "trl/trl/trainer/sft_trainer.py",
"repo_id": "trl",
"token_count": 28011
} | 605 |
- title: Unit 0. Welcome to the course
sections:
- local: unit0/introduction
title: Welcome to the course 🤗
- local: unit0/onboarding
title: Onboarding
- local: unit0/discord101
title: (Optional) Discord 101
- title: Live 1. How the course works and Q&A
sections:
- local: communication/live1
... | agents-course/units/en/_toctree.yml/0 | {
"file_path": "agents-course/units/en/_toctree.yml",
"repo_id": "agents-course",
"token_count": 2077
} | 0 |
# (Optional) Discord 101 [[discord-101]]
<img src="https://huggingface.co/datasets/agents-course/course-images/resolve/main/en/unit0/discord-etiquette.jpg" alt="The Discord Etiquette" width="100%"/>
This guide is designed to help you get started with Discord, a free chat platform popular in the gaming and ML communit... | agents-course/units/en/unit0/discord101.mdx/0 | {
"file_path": "agents-course/units/en/unit0/discord101.mdx",
"repo_id": "agents-course",
"token_count": 764
} | 1 |
# Let's Create Our First Agent Using smolagents
In the last section, we learned how we can create Agents from scratch using Python code, and we **saw just how tedious that process can be**. Fortunately, many Agent libraries simplify this work by **handling much of the heavy lifting for you**.
In this tutorial, **you'... | agents-course/units/en/unit1/tutorial.mdx/0 | {
"file_path": "agents-course/units/en/unit1/tutorial.mdx",
"repo_id": "agents-course",
"token_count": 3262
} | 2 |
# Introduction to the LlamaHub
**LlamaHub is a registry of hundreds of integrations, agents and tools that you can use within LlamaIndex.**

We will be using various integrations in this course, so... | agents-course/units/en/unit2/llama-index/llama-hub.mdx/0 | {
"file_path": "agents-course/units/en/unit2/llama-index/llama-hub.mdx",
"repo_id": "agents-course",
"token_count": 637
} | 3 |

# Why use smolagents
In this module, we will explore the pros and cons of using [smolagents](https://huggingface.co/docs/smolagents/en/index), helping you make an informed decision about w... | agents-course/units/en/unit2/smolagents/why_use_smolagents.mdx/0 | {
"file_path": "agents-course/units/en/unit2/smolagents/why_use_smolagents.mdx",
"repo_id": "agents-course",
"token_count": 1410
} | 4 |
# Hagamos Fine-Tuning de Tu Modelo para Llamadas a Funciones
Ahora estamos listos para hacer fine-tuning de nuestro primer modelo para llamadas a funciones 🔥.
## ¿Cómo entrenamos nuestro modelo para llamadas a funciones?
> Respuesta: Necesitamos **datos**
Un proceso de entrenamiento de modelo se puede dividir en 3... | agents-course/units/es/bonus-unit1/fine-tuning.mdx/0 | {
"file_path": "agents-course/units/es/bonus-unit1/fine-tuning.mdx",
"repo_id": "agents-course",
"token_count": 1585
} | 5 |
# Incorporación: Tus Primeros Pasos ⛵
<img src="https://huggingface.co/datasets/agents-course/course-images/resolve/main/en/unit0/time-to-onboard.jpg" alt="Hora de Incorporarse" width="100%"/>
Ahora que tienes todos los detalles, ¡comencemos! Vamos a hacer cuatro cosas:
1. **Crear tu Cuenta de Hugging Face** si aún ... | agents-course/units/es/unit0/onboarding.mdx/0 | {
"file_path": "agents-course/units/es/unit0/onboarding.mdx",
"repo_id": "agents-course",
"token_count": 1131
} | 6 |
# ¿Qué son los LLMs?
<img src="https://huggingface.co/datasets/agents-course/course-images/resolve/main/en/unit1/whiteboard-check-1.jpg" alt="Planificación de la Unidad 1"/>
En la sección anterior aprendimos que cada Agente necesita **un Modelo de IA en su núcleo**, y que los LLMs son el tipo más común de modelos de ... | agents-course/units/es/unit1/what-are-llms.mdx/0 | {
"file_path": "agents-course/units/es/unit1/what-are-llms.mdx",
"repo_id": "agents-course",
"token_count": 5215
} | 7 |
# Autoevaluación Rápida (sin calificar) [[quiz2]]
¿Qué?! Otra autoevaluación? Lo sabemos, lo sabemos, ... 😅 Pero esta breve autoevaluación no calificada está aquí para **ayudarte a reforzar conceptos clave que acabas de aprender**.
Esta evaluación cubre flujos de trabajo de agentes y interacciones - componentes ese... | agents-course/units/es/unit2/llama-index/quiz2.mdx/0 | {
"file_path": "agents-course/units/es/unit2/llama-index/quiz2.mdx",
"repo_id": "agents-course",
"token_count": 1176
} | 8 |
# Creando tu Agente para la Gala
Ahora que hemos construido todos los componentes necesarios para Alfred, es momento de unirlos en un agente completo que pueda ayudar a organizar nuestra extravagante gala.
En esta sección, combinaremos la recuperación de información de invitados, búsqueda web, información meteorológi... | agents-course/units/es/unit3/agentic-rag/agent.mdx/0 | {
"file_path": "agents-course/units/es/unit3/agentic-rag/agent.mdx",
"repo_id": "agents-course",
"token_count": 7498
} | 9 |
# Introduction

Bienvenue dans cette première **Unité Bonus**, où vous apprendrez à **finetuner un LLM pour de l'appel de fonctions** (*function calling*).
En termes de LLM, l'appel de fonc... | agents-course/units/fr/bonus-unit1/introduction.mdx/0 | {
"file_path": "agents-course/units/fr/bonus-unit1/introduction.mdx",
"repo_id": "agents-course",
"token_count": 1201
} | 10 |
# Table des matières
Vous pouvez accéder à l'Unité 1 sur hf.co/learn 👉 <a href="https://hf.co/learn/agents-course/unit1/introduction">ici</a>
<!--
| Titre | Description |
|-------|-------------|
| [Définition d'un Agent](1_definition_of_an_agent.md) | Exemple général de ce que les agents peuvent faire sans jargon te... | agents-course/units/fr/unit1/README.md/0 | {
"file_path": "agents-course/units/fr/unit1/README.md",
"repo_id": "agents-course",
"token_count": 600
} | 11 |
# Introduction aux frameworks agentiques
<img src="https://huggingface.co/datasets/agents-course/course-images/resolve/main/en/unit2/thumbnail.jpg" alt="Thumbnail"/>
Bienvenue dans cette deuxième unité, où **nous explorerons différents frameworks agentiques** qui peuvent être utilisés pour construire de puissantes ap... | agents-course/units/fr/unit2/introduction.mdx/0 | {
"file_path": "agents-course/units/fr/unit2/introduction.mdx",
"repo_id": "agents-course",
"token_count": 991
} | 12 |
# Utiliser les outils dans LlamaIndex
**Définir un ensemble clair d'outils est crucial pour la performance.** Comme nous l'avons discuté dans l'[Unité 1](../../unit1/tools), des interfaces claires sont plus faciles à utiliser pour les LLM.
Tout comme une interface API logicielle pour les ingénieurs humains, ils peuven... | agents-course/units/fr/unit2/llama-index/tools.mdx/0 | {
"file_path": "agents-course/units/fr/unit2/llama-index/tools.mdx",
"repo_id": "agents-course",
"token_count": 2873
} | 13 |
# RAG agentique
Dans cette unité, nous allons examiner comment nous pouvons utiliser le *RAG agentique* pour aider Alfred à préparer l'incroyable gala.
<Tip>Nous avons déjà discuté du RAG et du RAG agentique dans l'unité précédente, donc n'hésitez pas à passer directement à la suite si vous êtes déjà familier avec ce... | agents-course/units/fr/unit3/agentic-rag/agentic-rag.mdx/0 | {
"file_path": "agents-course/units/fr/unit3/agentic-rag/agentic-rag.mdx",
"repo_id": "agents-course",
"token_count": 742
} | 14 |
# 액션: 에이전트가 환경과 상호작용할 수 있게 하기 [[actions-enabling-the-agent-to-engage-with-its-environment]]
<Tip>
이 섹션에서는 AI 에이전트가 환경과 상호작용하기 위해 취하는 구체적인 단계를 살펴봅니다.
액션이 어떻게 표현되는지(JSON 또는 코드 사용), 중지 및 구문 분석 접근 방식의 중요성, 그리고 다양한 유형의 에이전트를 소개합니다.
</Tip>
액션은 **AI 에이전트가 환경과 상호작용하기 위해 취하는** 구체적인 단계입니다.
정보를 위해 웹을 검색하든 물리적 장치를 제어하든, 각 액... | agents-course/units/ko/unit1/actions.mdx/0 | {
"file_path": "agents-course/units/ko/unit1/actions.mdx",
"repo_id": "agents-course",
"token_count": 5570
} | 15 |
# Заключение [[conclusion]]
Поздравляем вас с завершением этого первого бонусного раздела 🥳.
Вы только что **овладели пониманием вызова функций и тем, как дообучить свою модель вызову функций**!
Если у нас и есть теперь совет, то это попробовать **дообучить другие модели**. **Лучший способ учиться - это пробовать**... | agents-course/units/ru-RU/bonus-unit1/conclusion.mdx/0 | {
"file_path": "agents-course/units/ru-RU/bonus-unit1/conclusion.mdx",
"repo_id": "agents-course",
"token_count": 733
} | 16 |
# Введение в Агентов
<img src="https://huggingface.co/datasets/agents-course/course-images/resolve/main/en/unit1/thumbnail.jpg" alt="Thumbnail"/>
Добро пожаловать в первый раздел, где **вы заложите прочный фундамент основ ИИ-агентов**, включая:
- **Понимание агентов**
- Что такое агент и как он работает?
- К... | agents-course/units/ru-RU/unit1/introduction.mdx/0 | {
"file_path": "agents-course/units/ru-RU/unit1/introduction.mdx",
"repo_id": "agents-course",
"token_count": 1625
} | 17 |
# Khi nào các chương tiếp theo được công bố?
Đây là lịch công bố:
<img src="https://huggingface.co/datasets/agents-course/course-images/resolve/main/en/communication/next-units.jpg" alt="Next Units" width="100%"/>
Đừng quên <a href="https://bit.ly/hf-learn-agents">đăng ký khóa học</a>! Khi đăng ký, **chúng mình sẽ g... | agents-course/units/vi/communication/next-units.mdx/0 | {
"file_path": "agents-course/units/vi/communication/next-units.mdx",
"repo_id": "agents-course",
"token_count": 319
} | 18 |
# Hãy tạo Agent đầu tiên của chúng ta với smolagents
Ở chương trước, ta đã học cách tạo Agent từ đầu bằng Python và **thấy quá trình này tốn công thế nào**. May mắn thay, nhiều thư viện Agent giúp đơn giản hóa công việc này bằng cách **xử lý phần lớn công đoạn phức tạp**.
Trong bài thực hành này, **bạn sẽ tạo Agent đ... | agents-course/units/vi/unit1/tutorial.mdx/0 | {
"file_path": "agents-course/units/vi/unit1/tutorial.mdx",
"repo_id": "agents-course",
"token_count": 5528
} | 19 |
# 后续单元发布时间表及常见问题解答
课程单元发布时间安排如下:
<img src="https://huggingface.co/datasets/agents-course/course-images/resolve/main/en/communication/next-units.jpg" alt="下一单元" width="100%"/>
请务必 <a href="https://bit.ly/hf-learn-agents">完成课程注册</a>! 完成注册后, **我们将随单元发布进度为您推送专属学习链接,同步更新挑战任务详情及课程动态**。
持续精进,成就卓越 🤗 | agents-course/units/zh-CN/communication/next-units.mdx/0 | {
"file_path": "agents-course/units/zh-CN/communication/next-units.mdx",
"repo_id": "agents-course",
"token_count": 290
} | 20 |
# 什么是工具?
<img src="https://huggingface.co/datasets/agents-course/course-images/resolve/main/en/unit1/whiteboard-check-2.jpg" alt="Unit 1 planning"/>
AI 智能体的关键能力在于执行**行动**。正如前文所述,这通过**工具**的使用实现。
本节将学习工具的定义、有效设计方法,以及如何通过系统消息将其集成到智能体中。
通过为智能体配备合适的工具——并清晰描述这些工具的工作原理——可显著提升 AI 的能力边界。让我们深入探讨!
## AI 工具的定义
**工具是赋予 LLM 的函... | agents-course/units/zh-CN/unit1/tools.mdx/0 | {
"file_path": "agents-course/units/zh-CN/unit1/tools.mdx",
"repo_id": "agents-course",
"token_count": 7598
} | 21 |
# LlamaIndex 简介
欢迎来到本模块,您将学习如何使用 [LlamaIndex](https://www.llamaindex.ai/) 工具包构建基于大语言模型(LLM)的智能体。
LlamaIndex 是**通过索引和工作流在您的数据上创建 LLM 驱动智能体的完整工具包**。本课程我们将重点关注构建 LlamaIndex 智能体的三个核心部分:**组件**、**智能体与工具**以及**工作流**。
 -> Result<Tensor> {
let x = image.matmul... | candle/candle-book/src/guide/mnist/modeling.md/0 | {
"file_path": "candle/candle-book/src/guide/mnist/modeling.md",
"repo_id": "candle",
"token_count": 1740
} | 25 |
[package]
name = "candle-core"
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 }
byteorder =... | candle/candle-core/Cargo.toml/0 | {
"file_path": "candle/candle-core/Cargo.toml",
"repo_id": "candle",
"token_count": 604
} | 26 |
#[cfg(feature = "mkl")]
extern crate intel_mkl_src;
#[cfg(feature = "accelerate")]
extern crate accelerate_src;
use std::str::FromStr;
use anyhow::Result;
use candle_core::{Device, Tensor};
fn cos_sin(n: usize, device: &Device) -> Result<Tensor> {
let thetas: Vec<_> = (0..n).map(|i| (i as f32 / n as f32)).colle... | candle/candle-core/examples/cuda_sum_benchmark.rs/0 | {
"file_path": "candle/candle-core/examples/cuda_sum_benchmark.rs",
"repo_id": "candle",
"token_count": 827
} | 27 |
use crate::backend::BackendDevice;
use crate::{CpuStorage, CpuStorageRef, DType, Layout, Result, Shape};
pub use candle_kernels as kernels;
pub use cudarc;
use cudarc::driver::CudaFunction;
use float8::F8E4M3;
use half::{bf16, f16};
use std::collections::HashMap;
use std::sync::{Arc, Mutex};
use super::{CudaError, Cud... | candle/candle-core/src/cuda_backend/device.rs/0 | {
"file_path": "candle/candle-core/src/cuda_backend/device.rs",
"repo_id": "candle",
"token_count": 10496
} | 28 |
#![allow(dead_code)]
use libc::{c_char, c_double, c_float, c_int};
mod ffi {
use super::*;
extern "C" {
pub fn vsTanh(n: c_int, a: *const c_float, y: *mut c_float);
pub fn vdTanh(n: c_int, a: *const c_double, y: *mut c_double);
pub fn vsExp(n: c_int, a: *const c_float, y: *mut c_float);... | candle/candle-core/src/mkl.rs/0 | {
"file_path": "candle/candle-core/src/mkl.rs",
"repo_id": "candle",
"token_count": 6463
} | 29 |
//! Module to load `safetensor` files into CPU/GPU memory.
//!
//! There are multiple ways to load tensors from safetensor files:
//! - `load` function for loading directly into memory and returning a HashMap of tensors
//! - `MmapedSafetensors` for memory mapping files and avoiding full allocation
//! - `SliceSafetens... | candle/candle-core/src/safetensors.rs/0 | {
"file_path": "candle/candle-core/src/safetensors.rs",
"repo_id": "candle",
"token_count": 8785
} | 30 |
#![allow(clippy::approx_constant)]
use anyhow::{Context, Result};
use candle_core::{test_device, test_utils, DType, Device, Shape, Tensor, Var};
fn simple_grad(device: &Device) -> Result<()> {
let x = Var::new(&[3f32, 1., 4.], device)?;
let x = x.as_tensor();
let y = (((x * x)? + x * 5f64)? + 4f64)?;
l... | candle/candle-core/tests/grad_tests.rs/0 | {
"file_path": "candle/candle-core/tests/grad_tests.rs",
"repo_id": "candle",
"token_count": 9586
} | 31 |
# candle-datasets
| candle/candle-datasets/README.md/0 | {
"file_path": "candle/candle-datasets/README.md",
"repo_id": "candle",
"token_count": 7
} | 32 |
//! BEiT: BERT Pre-Training of Image Transformers
//! https://github.com/microsoft/unilm/tree/master/beit
#[cfg(feature = "mkl")]
extern crate intel_mkl_src;
#[cfg(feature = "accelerate")]
extern crate accelerate_src;
use clap::Parser;
use candle::{DType, Device, IndexOp, Result, Tensor, D};
use candle_nn::{Module,... | candle/candle-examples/examples/beit/main.rs/0 | {
"file_path": "candle/candle-examples/examples/beit/main.rs",
"repo_id": "candle",
"token_count": 1178
} | 33 |
use anyhow::{Error as E, Result};
use candle::{DType, Device, Tensor};
use candle_nn::VarBuilder;
use candle_transformers::models::colpali::Model;
use candle_transformers::models::{colpali, paligemma};
use clap::Parser;
use hf_hub::{api::sync::Api, Repo, RepoType};
use image::DynamicImage;
use pdf2image::{RenderOptions... | candle/candle-examples/examples/colpali/main.rs/0 | {
"file_path": "candle/candle-examples/examples/colpali/main.rs",
"repo_id": "candle",
"token_count": 3864
} | 34 |
# candle-granite LLMs from IBM Research
[Granite](https://www.ibm.com/granite) is a family of Large Language Models built for business, to help drive trust and scalability in AI-driven applications.
## Running the example
```bash
$ cargo run --example granite --features metal -r -- --model-type "granite7b-instruct" ... | candle/candle-examples/examples/granite/README.md/0 | {
"file_path": "candle/candle-examples/examples/granite/README.md",
"repo_id": "candle",
"token_count": 371
} | 35 |
pub const DEFAULT_IMAGE_TOKEN: &str = "<image>";
pub const DEFAULT_IM_START_TOKEN: &str = "<im_start>";
pub const DEFAULT_IM_END_TOKEN: &str = "<im_end>";
pub const IMAGE_PLACEHOLDER: &str = "<image-placeholder>";
| candle/candle-examples/examples/llava/constants.rs/0 | {
"file_path": "candle/candle-examples/examples/llava/constants.rs",
"repo_id": "candle",
"token_count": 86
} | 36 |
# candle-mimi
[Mimi](https://huggingface.co/kyutai/mimi) is a state of the art audio
compression model using an encoder/decoder architecture with residual vector
quantization. The candle implementation supports streaming meaning that it's
possible to encode or decode a stream of audio tokens on the flight to provide
l... | candle/candle-examples/examples/mimi/README.md/0 | {
"file_path": "candle/candle-examples/examples/mimi/README.md",
"repo_id": "candle",
"token_count": 228
} | 37 |
use std::path::PathBuf;
use anyhow::{Error as E, Result};
use candle::{Device, Tensor};
use candle_nn::VarBuilder;
use candle_transformers::models::modernbert;
use clap::{Parser, ValueEnum};
use hf_hub::{api::sync::Api, Repo, RepoType};
use tokenizers::{PaddingParams, Tokenizer};
#[derive(Debug, Clone, ValueEnum)]
en... | candle/candle-examples/examples/modernbert/main.rs/0 | {
"file_path": "candle/candle-examples/examples/modernbert/main.rs",
"repo_id": "candle",
"token_count": 2425
} | 38 |
#[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::{DType, Device, IndexOp, Tensor};
use candle_nn::VarBuilder;
use candle_transformers::models::llama::{Cache, Llama, LlamaConfig};
use candle_... | candle/candle-examples/examples/orpheus/main.rs/0 | {
"file_path": "candle/candle-examples/examples/orpheus/main.rs",
"repo_id": "candle",
"token_count": 5468
} | 39 |
# candle-quantized-qwen3
[Qwen3]((https://qwenlm.github.io/blog/qwen3/)) is an upgraded version of Qwen2.5, released by Alibaba Cloud.
## Running the example
```bash
cargo run --example quantized-qwen3 --release -- --prompt "Write a function to count prime numbers up to N."
```
0.6b is used by default, 1.7b, 4b, 8... | candle/candle-examples/examples/quantized-qwen3/README.md/0 | {
"file_path": "candle/candle-examples/examples/quantized-qwen3/README.md",
"repo_id": "candle",
"token_count": 186
} | 40 |
#[cfg(feature = "mkl")]
extern crate intel_mkl_src;
#[cfg(feature = "accelerate")]
extern crate accelerate_src;
use candle::Result;
use clap::{Parser, Subcommand};
mod gym_env;
mod vec_gym_env;
mod ddpg;
mod dqn;
mod policy_gradient;
#[derive(Parser)]
struct Args {
#[command(subcommand)]
command: Command,
... | candle/candle-examples/examples/reinforcement-learning/main.rs/0 | {
"file_path": "candle/candle-examples/examples/reinforcement-learning/main.rs",
"repo_id": "candle",
"token_count": 277
} | 41 |
use anyhow::{Ok, Result};
use candle::{DType, IndexOp, Tensor};
use candle_transformers::models::flux;
use candle_transformers::models::mmdit::model::MMDiT;
pub struct SkipLayerGuidanceConfig {
pub scale: f64,
pub start: f64,
pub end: f64,
pub layers: Vec<usize>,
}
#[allow(clippy::too_many_arguments)... | candle/candle-examples/examples/stable-diffusion-3/sampling.rs/0 | {
"file_path": "candle/candle-examples/examples/stable-diffusion-3/sampling.rs",
"repo_id": "candle",
"token_count": 1404
} | 42 |
#[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, Tensor};
use candle_examples::token_output_stream::TokenOutputStream;
use candle_nn::VarBuilder;
use candle_transformers::models::... | candle/candle-examples/examples/trocr/main.rs/0 | {
"file_path": "candle/candle-examples/examples/trocr/main.rs",
"repo_id": "candle",
"token_count": 2167
} | 43 |
// https://github.com/openai/whisper/blob/main/whisper/model.py/rgs
// TODO:
// - Batch size greater than 1.
// - More token filters (SuppressBlanks, ApplyTimestampRules).
#[cfg(feature = "accelerate")]
extern crate accelerate_src;
#[cfg(feature = "mkl")]
extern crate intel_mkl_src;
use anyhow::{Error as E, Result};... | candle/candle-examples/examples/whisper/main.rs/0 | {
"file_path": "candle/candle-examples/examples/whisper/main.rs",
"repo_id": "candle",
"token_count": 14388
} | 44 |
# candle-yolo-v8: Object Detection and Pose Estimation
This is a port of [Ultralytics
YOLOv8](https://github.com/ultralytics/ultralytics). The implementation is based
on the [tinygrad
version](https://github.com/tinygrad/tinygrad/blob/master/examples/yolov8.py)
and on the model architecture described in this
[issue](h... | candle/candle-examples/examples/yolo-v8/README.md/0 | {
"file_path": "candle/candle-examples/examples/yolo-v8/README.md",
"repo_id": "candle",
"token_count": 562
} | 45 |
# candle-flash-attn
| candle/candle-flash-attn/README.md/0 | {
"file_path": "candle/candle-flash-attn/README.md",
"repo_id": "candle",
"token_count": 8
} | 46 |
// Pytorch also has an implementation of Philox RNG: https://github.com/pytorch/pytorch/blob/8ca3c881db3e3510fcb7725389f6a0633c9b992c/torch/csrc/jit/tensorexpr/cuda_random.h
#pragma once
// Philox CUDA.
namespace flash {
struct ull2 {
unsigned long long x;
unsigned long long y;
};
__forceinline__ __device__ ... | candle/candle-flash-attn/kernels/philox.cuh/0 | {
"file_path": "candle/candle-flash-attn/kernels/philox.cuh",
"repo_id": "candle",
"token_count": 770
} | 47 |
#include "cuda_utils.cuh"
#include<stdint.h>
// Naive implementation of conv1d.
template <typename T, typename A>
__device__ void conv1d(
const size_t src_numel,
const size_t l_out,
const size_t stride,
const size_t padding,
const size_t dilation,
const size_t *info,
const T *src,
const... | candle/candle-kernels/src/conv.cu/0 | {
"file_path": "candle/candle-kernels/src/conv.cu",
"repo_id": "candle",
"token_count": 12097
} | 48 |
#include <metal_stdlib>
METAL_FUNC uint get_strided_index(
uint idx,
constant size_t &num_dims,
constant size_t *dims,
constant size_t *strides
) {
uint strided_i = 0;
for (uint d = 0; d < num_dims; d++) {
uint dim_idx = num_dims - 1 - d;
strided_i += (idx % dims[dim_idx]) * str... | candle/candle-metal-kernels/src/cast.metal/0 | {
"file_path": "candle/candle-metal-kernels/src/cast.metal",
"repo_id": "candle",
"token_count": 2045
} | 49 |
#include <metal_stdlib>
#include <metal_math>
#
using namespace metal;
METAL_FUNC uint get_strided_index(
uint idx,
constant size_t &num_dims,
constant size_t *dims,
constant size_t *strides
) {
uint strided_i = 0;
for (uint d = 0; d < num_dims; d++) {
uint dim_idx = num_dims - 1 - d;
... | candle/candle-metal-kernels/src/unary.metal/0 | {
"file_path": "candle/candle-metal-kernels/src/unary.metal",
"repo_id": "candle",
"token_count": 3219
} | 50 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.