text stringlengths 96 319k | id stringlengths 14 178 | metadata dict |
|---|---|---|
# coding=utf-8
# 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 r... | transformers/tests/models/trocr/test_modeling_trocr.py/0 | {
"file_path": "transformers/tests/models/trocr/test_modeling_trocr.py",
"repo_id": "transformers",
"token_count": 3182
} |
# 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/univnet/test_feature_extraction_univnet.py/0 | {
"file_path": "transformers/tests/models/univnet/test_feature_extraction_univnet.py",
"repo_id": "transformers",
"token_count": 7239
} |
# coding=utf-8
# 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 r... | transformers/tests/models/vits/test_modeling_vits.py/0 | {
"file_path": "transformers/tests/models/vits/test_modeling_vits.py",
"repo_id": "transformers",
"token_count": 9245
} |
# coding=utf-8
# 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 r... | transformers/tests/models/wav2vec2_conformer/test_modeling_wav2vec2_conformer.py/0 | {
"file_path": "transformers/tests/models/wav2vec2_conformer/test_modeling_wav2vec2_conformer.py",
"repo_id": "transformers",
"token_count": 18096
} |
# 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/zoedepth/test_image_processing_zoedepth.py/0 | {
"file_path": "transformers/tests/models/zoedepth/test_image_processing_zoedepth.py",
"repo_id": "transformers",
"token_count": 3055
} |
# 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_image_segmentation.py/0 | {
"file_path": "transformers/tests/pipelines/test_pipelines_image_segmentation.py",
"repo_id": "transformers",
"token_count": 15853
} |
# Copyright 2022 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_visual_question_answering.py/0 | {
"file_path": "transformers/tests/pipelines/test_pipelines_visual_question_answering.py",
"repo_id": "transformers",
"token_count": 4269
} |
import gc
import unittest
from transformers import AutoModelForCausalLM, AutoTokenizer, CompressedTensorsConfig
from transformers.testing_utils import require_compressed_tensors, require_torch
from transformers.utils import is_torch_available
if is_torch_available():
import torch
@require_compressed_tensors
@r... | transformers/tests/quantization/compressed_tensor/test_compressed_tensors.py/0 | {
"file_path": "transformers/tests/quantization/compressed_tensor/test_compressed_tensors.py",
"repo_id": "transformers",
"token_count": 1688
} |
# coding=utf-8
# 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 ag... | transformers/tests/test_sequence_feature_extraction_common.py/0 | {
"file_path": "transformers/tests/test_sequence_feature_extraction_common.py",
"repo_id": "transformers",
"token_count": 7929
} |
# 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_dynamic_module_utils.py/0 | {
"file_path": "transformers/tests/utils/test_dynamic_module_utils.py",
"repo_id": "transformers",
"token_count": 918
} |
# coding=utf-8
# Copyright 2019 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/utils/test_modeling_utils.py/0 | {
"file_path": "transformers/tests/utils/test_modeling_utils.py",
"repo_id": "transformers",
"token_count": 55659
} |
# 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_dummies.py/0 | {
"file_path": "transformers/utils/check_dummies.py",
"repo_id": "transformers",
"token_count": 3338
} |
import argparse
import math
import traceback
import dateutil.parser as date_parser
import requests
def extract_time_from_single_job(job):
"""Extract time info from a single job in a GitHub Actions workflow run"""
job_info = {}
start = job["started_at"]
end = job["completed_at"]
start_datetime ... | transformers/utils/get_github_job_time.py/0 | {
"file_path": "transformers/utils/get_github_job_time.py",
"repo_id": "transformers",
"token_count": 835
} |
# 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/utils/process_circleci_workflow_test_reports.py/0 | {
"file_path": "transformers/utils/process_circleci_workflow_test_reports.py",
"repo_id": "transformers",
"token_count": 1573
} |
cff-version: 1.2.0
title: 'TRL: Transformer Reinforcement Learning'
message: >-
If you use this software, please cite it using the
metadata from this file.
type: software
authors:
- given-names: Leandro
family-names: von Werra
- given-names: Younes
family-names: Belkada
- given-names: Lewis
family... | trl/CITATION.cff/0 | {
"file_path": "trl/CITATION.cff",
"repo_id": "trl",
"token_count": 369
} |
# Command Line Interfaces (CLIs)
You can use TRL to fine-tune your Language Model with Supervised Fine-Tuning (SFT) or Direct Policy Optimization (DPO) or even chat with your model using the TRL CLIs.
Currently supported CLIs are:
#### Training commands
- `trl dpo`: fine-tune a LLM with DPO
- `trl grpo`: fine-tune ... | trl/docs/source/clis.md/0 | {
"file_path": "trl/docs/source/clis.md",
"repo_id": "trl",
"token_count": 2201
} |
# Iterative Trainer
[](https://huggingface.co/models?other=iterative-sft,trl)
Iterative fine-tuning is a training method that enables to perform custom actions (generation and filtering for example) between optimization steps. In TRL we provide an easy-t... | trl/docs/source/iterative_sft_trainer.md/0 | {
"file_path": "trl/docs/source/iterative_sft_trainer.md",
"repo_id": "trl",
"token_count": 441
} |
# Reward Modeling
[](https://huggingface.co/models?other=reward-trainer,trl)
TRL supports custom reward modeling for anyone to perform reward modeling on their dataset and model.
Check out a complete flexible example at [`examples/scripts/reward_modelin... | trl/docs/source/reward_trainer.md/0 | {
"file_path": "trl/docs/source/reward_trainer.md",
"repo_id": "trl",
"token_count": 1139
} |
<jupyter_start><jupyter_text>Tune GPT2 to generate positive reviews> Optimise GPT2 to produce positive IMDB movie reviews using a BERT sentiment classifier as a reward function. Figure: Experiment setup to tune GPT2. The yellow arrows are outside the scope of this notebook, but the trained models are available through... | trl/examples/notebooks/gpt2-sentiment.ipynb/0 | {
"file_path": "trl/examples/notebooks/gpt2-sentiment.ipynb",
"repo_id": "trl",
"token_count": 3695
} |
# 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... | trl/examples/research_projects/toxicity/scripts/gpt-j-6b-toxicity.py/0 | {
"file_path": "trl/examples/research_projects/toxicity/scripts/gpt-j-6b-toxicity.py",
"repo_id": "trl",
"token_count": 3135
} |
# 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... | trl/examples/scripts/prm.py/0 | {
"file_path": "trl/examples/scripts/prm.py",
"repo_id": "trl",
"token_count": 1702
} |
# 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... | trl/tests/test_data_collator_completion_only.py/0 | {
"file_path": "trl/tests/test_data_collator_completion_only.py",
"repo_id": "trl",
"token_count": 3404
} |
# 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... | trl/tests/test_peft_models.py/0 | {
"file_path": "trl/tests/test_peft_models.py",
"repo_id": "trl",
"token_count": 4092
} |
# 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... | trl/trl/scripts/dpo.py/0 | {
"file_path": "trl/trl/scripts/dpo.py",
"repo_id": "trl",
"token_count": 2024
} |
# 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... | trl/trl/trainer/ddpo_trainer.py/0 | {
"file_path": "trl/trl/trainer/ddpo_trainer.py",
"repo_id": "trl",
"token_count": 12992
} |
# 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... | trl/trl/trainer/orpo_config.py/0 | {
"file_path": "trl/trl/trainer/orpo_config.py",
"repo_id": "trl",
"token_count": 2486
} |
# 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... | accelerate/benchmarks/big_model_inference/measures_util.py/0 | {
"file_path": "accelerate/benchmarks/big_model_inference/measures_util.py",
"repo_id": "accelerate",
"token_count": 1146
} |
<!--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 applicable law or agreed... | accelerate/docs/source/concept_guides/internal_mechanism.md/0 | {
"file_path": "accelerate/docs/source/concept_guides/internal_mechanism.md",
"repo_id": "accelerate",
"token_count": 1178
} |
<!--Copyright 2022 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 applicable law or agreed... | accelerate/docs/source/usage_guides/gradient_accumulation.md/0 | {
"file_path": "accelerate/docs/source/usage_guides/gradient_accumulation.md",
"repo_id": "accelerate",
"token_count": 6972
} |
# Config Zoo
This folder contains a variety of minimal configurations for `Accelerate` achieving certain goals. You can use these
direct config YAML's, or build off of them for your own YAML's.
These are highly annoted versions, aiming to teach you what each section does.
Each config can be run via `accelerate laun... | accelerate/examples/config_yaml_templates/README.md/0 | {
"file_path": "accelerate/examples/config_yaml_templates/README.md",
"repo_id": "accelerate",
"token_count": 124
} |
# 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... | accelerate/examples/inference/distributed/distributed_speech_generation.py/0 | {
"file_path": "accelerate/examples/inference/distributed/distributed_speech_generation.py",
"repo_id": "accelerate",
"token_count": 3272
} |
#!/bin/bash
#SBATCH --job-name=multinode
#SBATCH -D .
#SBATCH --output=O-%x.%j
#SBATCH --error=E-%x.%j
#SBATCH --nodes=4 # number of nodes
#SBATCH --ntasks-per-node=1 # number of MP tasks
#SBATCH --gres=gpu:4 # number of GPUs per node
#SBATCH --cpus-per-task=160 # numbe... | accelerate/examples/slurm/submit_multinode.sh/0 | {
"file_path": "accelerate/examples/slurm/submit_multinode.sh",
"repo_id": "accelerate",
"token_count": 547
} |
# 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... | accelerate/setup.py/0 | {
"file_path": "accelerate/setup.py",
"repo_id": "accelerate",
"token_count": 1646
} |
#!/usr/bin/env python
# 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
#
# Unles... | accelerate/src/accelerate/commands/estimate.py/0 | {
"file_path": "accelerate/src/accelerate/commands/estimate.py",
"repo_id": "accelerate",
"token_count": 5035
} |
# 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... | accelerate/src/accelerate/local_sgd.py/0 | {
"file_path": "accelerate/src/accelerate/local_sgd.py",
"repo_id": "accelerate",
"token_count": 1577
} |
# 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... | accelerate/src/accelerate/test_utils/scripts/external_deps/test_zero3_integration.py/0 | {
"file_path": "accelerate/src/accelerate/test_utils/scripts/external_deps/test_zero3_integration.py",
"repo_id": "accelerate",
"token_count": 545
} |
# 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... | accelerate/src/accelerate/utils/deepspeed.py/0 | {
"file_path": "accelerate/src/accelerate/utils/deepspeed.py",
"repo_id": "accelerate",
"token_count": 5530
} |
# Copyright 2022 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... | accelerate/src/accelerate/utils/versions.py/0 | {
"file_path": "accelerate/src/accelerate/utils/versions.py",
"repo_id": "accelerate",
"token_count": 701
} |
# Copyright 2022 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... | accelerate/tests/test_optimizer.py/0 | {
"file_path": "accelerate/tests/test_optimizer.py",
"repo_id": "accelerate",
"token_count": 1194
} |
use crate::benchmarks::{BenchDevice, BenchDeviceHandler};
use candle_core::{DType, Device, Tensor};
use criterion::{black_box, criterion_group, Criterion, Throughput};
use std::time::Instant;
fn run(
x: &Tensor,
k: &Tensor,
padding: usize,
output_padding: usize,
stride: usize,
dilation: usize,
... | candle/candle-core/benches/benchmarks/conv_transpose2d.rs/0 | {
"file_path": "candle/candle-core/benches/benchmarks/conv_transpose2d.rs",
"repo_id": "candle",
"token_count": 826
} |
//! Implement conversion traits for tensors
use crate::{DType, Device, Error, Tensor, WithDType};
use half::{bf16, f16, slice::HalfFloatSliceExt};
use std::convert::TryFrom;
impl<T: WithDType> TryFrom<&Tensor> for Vec<T> {
type Error = Error;
fn try_from(tensor: &Tensor) -> Result<Self, Self::Error> {
... | candle/candle-core/src/convert.rs/0 | {
"file_path": "candle/candle-core/src/convert.rs",
"repo_id": "candle",
"token_count": 2242
} |
//! Pretty printing of tensors
//!
//! This implementation should be in line with the [PyTorch version](https://github.com/pytorch/pytorch/blob/7b419e8513a024e172eae767e24ec1b849976b13/torch/_tensor_str.py).
//!
use crate::{DType, Result, Tensor, WithDType};
use half::{bf16, f16};
impl Tensor {
fn fmt_dt<T: WithDT... | candle/candle-core/src/display.rs/0 | {
"file_path": "candle/candle-core/src/display.rs",
"repo_id": "candle",
"token_count": 9761
} |
#![allow(unused)]
use super::GgmlDType;
use crate::{CudaDevice, CudaStorage, Error, Result};
pub struct QCudaStorage {
dtype: GgmlDType,
device: CudaDevice,
}
impl QCudaStorage {
pub fn zeros(_: &CudaDevice, _: usize, _: GgmlDType) -> Result<Self> {
Err(Error::NotCompiledWithCudaSupport)
}
... | candle/candle-core/src/quantized/dummy_cuda.rs/0 | {
"file_path": "candle/candle-core/src/quantized/dummy_cuda.rs",
"repo_id": "candle",
"token_count": 594
} |
use crate::Layout;
/// An iterator over offset position for items of an N-dimensional arrays stored in a
/// flat buffer using some potential strides.
#[derive(Debug)]
pub struct StridedIndex<'a> {
next_storage_index: Option<usize>,
multi_index: Vec<usize>,
dims: &'a [usize],
stride: &'a [usize],
}
im... | candle/candle-core/src/strided_index.rs/0 | {
"file_path": "candle/candle-core/src/strided_index.rs",
"repo_id": "candle",
"token_count": 1094
} |
import torch
from collections import OrderedDict
# Write a trivial tensor to a pt file
a= torch.tensor([[1,2,3,4], [5,6,7,8]])
o = OrderedDict()
o["test"] = a
# Write a trivial tensor to a pt file
torch.save(o, "test.pt")
###############################################################################################... | candle/candle-core/tests/pth.py/0 | {
"file_path": "candle/candle-core/tests/pth.py",
"repo_id": "candle",
"token_count": 441
} |
//! The CIFAR-10 dataset.
//!
//! The files can be downloaded from the following page:
//! <https://www.cs.toronto.edu/~kriz/cifar.html>
//! The binary version of the dataset is used.
use crate::vision::Dataset;
use candle::{DType, Device, Error, Result, Tensor};
use hf_hub::{api::sync::Api, Repo, RepoType};
use parque... | candle/candle-datasets/src/vision/cifar.rs/0 | {
"file_path": "candle/candle-datasets/src/vision/cifar.rs",
"repo_id": "candle",
"token_count": 2139
} |
#[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::chatglm::{Config, Model};
use candle::{DType, Device, Tensor};
use candle_nn::VarBuilder;
use candle_transformers::gene... | candle/candle-examples/examples/chatglm/main.rs/0 | {
"file_path": "candle/candle-examples/examples/chatglm/main.rs",
"repo_id": "candle",
"token_count": 3423
} |
#[cfg(feature = "mkl")]
extern crate intel_mkl_src;
#[cfg(feature = "accelerate")]
extern crate accelerate_src;
use std::fmt::Display;
use std::path::PathBuf;
use anyhow::bail;
use anyhow::{Error as E, Result};
use candle::{Device, Tensor};
use candle_nn::ops::softmax;
use candle_nn::VarBuilder;
use candle_transform... | candle/candle-examples/examples/debertav2/main.rs/0 | {
"file_path": "candle/candle-examples/examples/debertav2/main.rs",
"repo_id": "candle",
"token_count": 6817
} |
use std::cmp::min;
use candle::{bail, DType, Device, Result, Tensor};
use candle_transformers::models::llava::{
config::{HFPreProcessorConfig, LLaVAConfig},
utils::select_best_resolution,
};
use hf_hub::api::sync::Api;
use image::{imageops::overlay, DynamicImage, GenericImageView, Rgb, RgbImage};
use serde::{D... | candle/candle-examples/examples/llava/image_processor.rs/0 | {
"file_path": "candle/candle-examples/examples/llava/image_processor.rs",
"repo_id": "candle",
"token_count": 4904
} |
# candle-mistral: 7b LLM with Apache 2.0 licensed weights
Mistral-7B-v0.1 is a pretrained generative LLM with 7 billion parameters. It outperforms all the publicly available 13b models
as of 2023-09-28. Weights (and the original Python model code) are released under the permissive Apache 2.0 license.
- [Blog post](ht... | candle/candle-examples/examples/mistral/README.md/0 | {
"file_path": "candle/candle-examples/examples/mistral/README.md",
"repo_id": "candle",
"token_count": 829
} |
use candle::{DType, Device, Result, Tensor, D};
use candle_nn::{
embedding, layer_norm, linear_no_bias, Activation, Embedding, LayerNorm, Linear, Module,
VarBuilder,
};
use candle_transformers::models::{encodec, t5};
// https://github.com/huggingface/transformers/blob/cd4584e3c809bb9e1392ccd3fe38b40daba5519a/s... | candle/candle-examples/examples/musicgen/musicgen_model.rs/0 | {
"file_path": "candle/candle-examples/examples/musicgen/musicgen_model.rs",
"repo_id": "candle",
"token_count": 7592
} |
#[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::pixtral::{vision_model, Config, Model};
use candle::{DType, Device, Module, Tensor};
use candle_examples::token_output_... | candle/candle-examples/examples/pixtral/main.rs/0 | {
"file_path": "candle/candle-examples/examples/pixtral/main.rs",
"repo_id": "candle",
"token_count": 5495
} |
use std::collections::VecDeque;
use rand::distributions::Uniform;
use rand::{thread_rng, Rng};
use candle::{DType, Device, Module, Result, Tensor};
use candle_nn::loss::mse;
use candle_nn::{linear, seq, Activation, AdamW, Optimizer, VarBuilder, VarMap};
use crate::gym_env::GymEnv;
const DEVICE: Device = Device::Cpu... | candle/candle-examples/examples/reinforcement-learning/dqn.rs/0 | {
"file_path": "candle/candle-examples/examples/reinforcement-learning/dqn.rs",
"repo_id": "candle",
"token_count": 2032
} |
use candle::Device;
use candle::Module;
use candle_nn::VarBuilder;
use candle_transformers::models::segformer::{
Config, ImageClassificationModel, SemanticSegmentationModel,
};
use clap::{Args, Parser, Subcommand};
use imageproc::image::Rgb;
use imageproc::integral_image::ArrayData;
use std::collections::HashMap;
u... | candle/candle-examples/examples/segformer/main.rs/0 | {
"file_path": "candle/candle-examples/examples/segformer/main.rs",
"repo_id": "candle",
"token_count": 2229
} |
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
} |
# candle-trocr
`TrOCR` is a transformer OCR Model. In this example it is used to
transcribe image text. See the associated [model
card](https://huggingface.co/microsoft/trocr-base-printed) for details on
the model itself.
Supported models include:
- `--which base`: small handwritten OCR model.
- `--which large`: lar... | candle/candle-examples/examples/trocr/readme.md/0 | {
"file_path": "candle/candle-examples/examples/trocr/readme.md",
"repo_id": "candle",
"token_count": 360
} |
#[cfg(feature = "accelerate")]
extern crate accelerate_src;
#[cfg(feature = "mkl")]
extern crate intel_mkl_src;
use candle_transformers::models::stable_diffusion;
use candle_transformers::models::wuerstchen;
use anyhow::{Error as E, Result};
use candle::{DType, Device, IndexOp, Tensor};
use clap::Parser;
use tokeniz... | candle/candle-examples/examples/wuerstchen/main.rs/0 | {
"file_path": "candle/candle-examples/examples/wuerstchen/main.rs",
"repo_id": "candle",
"token_count": 6372
} |
use candle::{Result, Tensor};
// https://github.com/facebookresearch/audiocraft/blob/69fea8b290ad1b4b40d28f92d1dfc0ab01dbab85/audiocraft/data/audio_utils.py#L57
pub fn normalize_loudness(
wav: &Tensor,
sample_rate: u32,
loudness_compressor: bool,
) -> Result<Tensor> {
let energy = wav.sqr()?.mean_all()... | candle/candle-examples/src/audio.rs/0 | {
"file_path": "candle/candle-examples/src/audio.rs",
"repo_id": "candle",
"token_count": 458
} |
/******************************************************************************
* Copyright (c) 2024, Tri Dao.
******************************************************************************/
#pragma once
// #include "philox_unpack.cuh" // For at::cuda::philox::unpack
#include <cute/tensor.hpp>
#include <cutlass/c... | candle/candle-flash-attn/kernels/flash_fwd_kernel.h/0 | {
"file_path": "candle/candle-flash-attn/kernels/flash_fwd_kernel.h",
"repo_id": "candle",
"token_count": 37133
} |
[package]
name = "candle-kernels"
version = "0.8.2"
edition = "2021"
description = "CUDA kernels for Candle"
repository = "https://github.com/huggingface/candle"
keywords = ["blas", "tensor", "machine-learning"]
categories = ["science"]
license = "MIT OR Apache-2.0"
[dependencies]
[build-dependencies]
bindgen_cuda =... | candle/candle-kernels/Cargo.toml/0 | {
"file_path": "candle/candle-kernels/Cargo.toml",
"repo_id": "candle",
"token_count": 126
} |
#include "cuda_utils.cuh"
#include<stdint.h>
#define WHERE_OP(TYPENAME, ID_TYPENAME, FN_NAME) \
extern "C" __global__ void FN_NAME( \
const size_t numel, \
const size_t num_dims, \
const size_t *info, \
const ID_TYPENAME *ids, \
const TYPENAME *t, \
const TYPENAME *f, \
TYPENAME *out \
) ... | candle/candle-kernels/src/ternary.cu/0 | {
"file_path": "candle/candle-kernels/src/ternary.cu",
"repo_id": "candle",
"token_count": 1159
} |
#include <metal_stdlib>
#include <metal_integer>
#include <metal_atomic>
using namespace metal;
// Constants
// 2^32 and 1/2^32. Useful for converting between float and uint.
static constexpr constant ulong UNIF01_NORM32 = 4294967296;
static constexpr constant float UNIF01_INV32 = 2.328306436538696289e-10;
// 2 * pi
... | candle/candle-metal-kernels/src/random.metal/0 | {
"file_path": "candle/candle-metal-kernels/src/random.metal",
"repo_id": "candle",
"token_count": 3671
} |
//! Layer Normalization.
//!
//! This layer applies Layer Normalization over a mini-batch of inputs as described in [`Layer
//! Normalization`]. The input is expected to have three dimensions: a batch dimension, a length,
//! and a hidden size, the normalization is applied over the last dimension.
//!
//! # Example
//!... | candle/candle-nn/src/layer_norm.rs/0 | {
"file_path": "candle/candle-nn/src/layer_norm.rs",
"repo_id": "candle",
"token_count": 2656
} |
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
} |
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
} |
import candle
from candle import Tensor
from candle.nn import Linear
def test_linear_layer_can_be_constructed():
linear = Linear(10, 10)
assert linear is not None
def test_linear_layer_can_forward_a_singular_input():
linear = Linear(384, 1536)
input_tensor = candle.randn((8, 384))
output = linea... | candle/candle-pyo3/tests/bindings/test_linear.py/0 | {
"file_path": "candle/candle-pyo3/tests/bindings/test_linear.py",
"repo_id": "candle",
"token_count": 431
} |
//! Implementation of DistilBert, a distilled version of BERT.
//!
//! See:
//! - ["DistilBERT, a distilled version of BERT: smaller, faster, cheaper and lighter"](https://arxiv.org/abs/1910.01108)
//!
use super::with_tracing::{layer_norm, linear, LayerNorm, Linear};
use candle::{DType, Device, Result, Tensor};
use can... | candle/candle-transformers/src/models/distilbert.rs/0 | {
"file_path": "candle/candle-transformers/src/models/distilbert.rs",
"repo_id": "candle",
"token_count": 5451
} |
//! Helium inference implementation.
//!
//! See the model card on Hugging Face's [hub](https://huggingface.co/kmhf/helium-2b).
use super::with_tracing::{linear_b as linear, Linear, RmsNorm};
use candle::{DType, Device, Result, Tensor, D};
use candle_nn::{Module, VarBuilder};
use std::sync::Arc;
fn default_use_flash_... | candle/candle-transformers/src/models/helium.rs/0 | {
"file_path": "candle/candle-transformers/src/models/helium.rs",
"repo_id": "candle",
"token_count": 6786
} |
// Copyright (c) Kyutai, all rights reserved.
// This source code is licensed under the license found in the
// LICENSE file in the root directory of this source tree.
use candle::{streaming, Module, Result, StreamTensor, StreamingModule, Tensor};
use candle_nn::VarBuilder;
use super::conv::{StreamableConv1d, Streama... | candle/candle-transformers/src/models/mimi/seanet.rs/0 | {
"file_path": "candle/candle-transformers/src/models/mimi/seanet.rs",
"repo_id": "candle",
"token_count": 8092
} |
//! Module implementing the MPT (Multi-Purpose Transformer) model
//!
//! References:
//! - [MPT Model used by replit-code-v1_5-3b](https://huggingface.co/replit/replit-code-v1_5-3b/blob/main/modeling_mpt.py)
//! - [Configuration](https://huggingface.co/replit/replit-code-v1_5-3b/blob/main/configuration_mpt.py)
//!
//!... | candle/candle-transformers/src/models/mpt.rs/0 | {
"file_path": "candle/candle-transformers/src/models/mpt.rs",
"repo_id": "candle",
"token_count": 5366
} |
//! Qwen2 model implementation with quantization support.
//!
//! Qwen2 is a large language model from Alibaba optimized for efficiency.
//! This implementation provides quantization for reduced memory and compute.
//!
//! Key characteristics:
//! - Streaming decode support
//! - Grouped query attention (GQA)
//! - RMS... | candle/candle-transformers/src/models/qwen2.rs/0 | {
"file_path": "candle/candle-transformers/src/models/qwen2.rs",
"repo_id": "candle",
"token_count": 6864
} |
//! Attention Based Building Blocks
use candle::{DType, IndexOp, Result, Tensor, D};
use candle_nn as nn;
use candle_nn::Module;
#[derive(Debug)]
struct GeGlu {
proj: nn::Linear,
span: tracing::Span,
}
impl GeGlu {
fn new(vs: nn::VarBuilder, dim_in: usize, dim_out: usize) -> Result<Self> {
let pro... | candle/candle-transformers/src/models/stable_diffusion/attention.rs/0 | {
"file_path": "candle/candle-transformers/src/models/stable_diffusion/attention.rs",
"repo_id": "candle",
"token_count": 9788
} |
//! Stella v5 model implementation.
//!
//! Stella is a dense text embedding model optimized for retrieval and similarity tasks.
//! This implementation provides support for multiple embedding dimensions.
//!
//! Key characteristics:
//! - Dense text embeddings optimized for similarity search
//! - Multiple output dime... | candle/candle-transformers/src/models/stella_en_v5.rs/0 | {
"file_path": "candle/candle-transformers/src/models/stella_en_v5.rs",
"repo_id": "candle",
"token_count": 14806
} |
use super::common::{AttnBlock, ResBlock, TimestepBlock};
use candle::{DType, Result, Tensor, D};
use candle_nn::VarBuilder;
#[derive(Debug)]
struct Block {
res_block: ResBlock,
ts_block: TimestepBlock,
attn_block: AttnBlock,
}
#[derive(Debug)]
pub struct WPrior {
projection: candle_nn::Conv2d,
con... | candle/candle-transformers/src/models/wuerstchen/prior.rs/0 | {
"file_path": "candle/candle-transformers/src/models/wuerstchen/prior.rs",
"repo_id": "candle",
"token_count": 1920
} |
use candle::{DType, Device, Tensor};
use candle_nn::VarBuilder;
use candle_transformers::models::bert::{BertModel, Config};
use candle_wasm_example_bert::console_log;
use tokenizers::{PaddingParams, Tokenizer};
use wasm_bindgen::prelude::*;
#[wasm_bindgen]
pub struct Model {
bert: BertModel,
tokenizer: Tokeniz... | candle/candle-wasm-examples/bert/src/bin/m.rs/0 | {
"file_path": "candle/candle-wasm-examples/bert/src/bin/m.rs",
"repo_id": "candle",
"token_count": 1752
} |
import init, { Model } from "./build/m.js";
async function fetchArrayBuffer(url) {
const cacheName = "llama2c-candle-cache";
const cache = await caches.open(cacheName);
const cachedResponse = await cache.match(url);
if (cachedResponse) {
const data = await cachedResponse.arrayBuffer();
return new Uint8... | candle/candle-wasm-examples/llama2-c/llama2cWorker.js/0 | {
"file_path": "candle/candle-wasm-examples/llama2-c/llama2cWorker.js",
"repo_id": "candle",
"token_count": 1223
} |
[package]
name = "candle-wasm-example-phi"
version.workspace = true
edition.workspace = true
description.workspace = true
repository.workspace = true
keywords.workspace = true
categories.workspace = true
license.workspace = true
[dependencies]
candle = { workspace = true }
candle-nn = { workspace = true }
candle-trans... | candle/candle-wasm-examples/phi/Cargo.toml/0 | {
"file_path": "candle/candle-wasm-examples/phi/Cargo.toml",
"repo_id": "candle",
"token_count": 278
} |
//load Candle Bert Module wasm module
let init, ModelConditionalGeneration;
async function fetchArrayBuffer(url) {
const cacheName = "t5-candle-cache";
const cache = await caches.open(cacheName);
const cachedResponse = await cache.match(url);
if (cachedResponse) {
const data = await cachedResponse.arrayBuf... | candle/candle-wasm-examples/t5/T5ModelConditionalGeneration.js/0 | {
"file_path": "candle/candle-wasm-examples/t5/T5ModelConditionalGeneration.js",
"repo_id": "candle",
"token_count": 980
} |
pub const NAMES: [&str; 80] = [
"person",
"bicycle",
"car",
"motorbike",
"aeroplane",
"bus",
"train",
"truck",
"boat",
"traffic light",
"fire hydrant",
"stop sign",
"parking meter",
"bench",
"bird",
"cat",
"dog",
"horse",
"sheep",
"cow",
... | candle/candle-wasm-examples/yolo/src/coco_classes.rs/0 | {
"file_path": "candle/candle-wasm-examples/yolo/src/coco_classes.rs",
"repo_id": "candle",
"token_count": 648
} |
{
"editor.formatOnSave": true,
"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.codeActionsOnSave": {
"source.fixAll": "explicit"
},
"eslint.validate": ["javascript", "svelte"],
"[svelte]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
}
}
| chat-ui/.vscode/settings.json/0 | {
"file_path": "chat-ui/.vscode/settings.json",
"repo_id": "chat-ui",
"token_count": 118
} |
{{- if $.Values.monitoring.enabled }}
apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
labels: {{ include "labels.standard" . | nindent 4 }}
name: {{ include "name" . }}
namespace: {{ .Release.Namespace }}
spec:
selector:
matchLabels: {{ include "labels.standard" . | nindent 6 }}
endpoi... | chat-ui/chart/templates/service-monitor.yaml/0 | {
"file_path": "chat-ui/chart/templates/service-monitor.yaml",
"repo_id": "chat-ui",
"token_count": 144
} |
# Ollama
| Feature | Available |
| --------------------------- | --------- |
| [Tools](../tools) | No |
| [Multimodal](../multimodal) | No |
We also support the Ollama inference server. Spin up a model with
```bash
ollama run mistral
```
Then specify the endpoints like so... | chat-ui/docs/source/configuration/models/providers/ollama.md/0 | {
"file_path": "chat-ui/docs/source/configuration/models/providers/ollama.md",
"repo_id": "chat-ui",
"token_count": 468
} |
<script lang="ts">
import CopyToClipBoardBtn from "./CopyToClipBoardBtn.svelte";
import DOMPurify from "isomorphic-dompurify";
import hljs from "highlight.js";
interface Props {
code?: string;
lang?: string;
}
let { code = "", lang = "" }: Props = $props();
let highlightedCode = $derived(hljs.highlightAut... | chat-ui/src/lib/components/CodeBlock.svelte/0 | {
"file_path": "chat-ui/src/lib/components/CodeBlock.svelte",
"repo_id": "chat-ui",
"token_count": 401
} |
<script lang="ts">
import { onMount, onDestroy } from "svelte";
interface Props {
children?: import("svelte").Snippet;
}
let { children }: Props = $props();
let el: HTMLElement | undefined = $state();
onMount(() => {
el?.ownerDocument.body.appendChild(el);
});
onDestroy(() => {
if (el?.parentNode) {
... | chat-ui/src/lib/components/Portal.svelte/0 | {
"file_path": "chat-ui/src/lib/components/Portal.svelte",
"repo_id": "chat-ui",
"token_count": 179
} |
<script lang="ts">
import { createEventDispatcher } from "svelte";
import { base } from "$app/paths";
import { goto } from "$app/navigation";
import type { Model } from "$lib/types/Model";
import type { Assistant } from "$lib/types/Assistant";
import { useSettingsStore } from "$lib/stores/settings";
import { for... | chat-ui/src/lib/components/chat/AssistantIntroduction.svelte/0 | {
"file_path": "chat-ui/src/lib/components/chat/AssistantIntroduction.svelte",
"repo_id": "chat-ui",
"token_count": 2837
} |
import type { Migration } from ".";
import { collections } from "$lib/server/database";
import { ObjectId, type AnyBulkWriteOperation } from "mongodb";
import type { Assistant } from "$lib/types/Assistant";
import { generateSearchTokens } from "$lib/utils/searchTokens";
const migration: Migration = {
_id: new ObjectI... | chat-ui/src/lib/migrations/routines/01-update-search-assistants.ts/0 | {
"file_path": "chat-ui/src/lib/migrations/routines/01-update-search-assistants.ts",
"repo_id": "chat-ui",
"token_count": 483
} |
import { z } from "zod";
import type { EmbeddingEndpoint, Embedding } from "../embeddingEndpoints";
import { chunk } from "$lib/utils/chunk";
import { env } from "$env/dynamic/private";
export const embeddingEndpointOpenAIParametersSchema = z.object({
weight: z.number().int().positive().default(1),
model: z.any(),
... | chat-ui/src/lib/server/embeddingEndpoints/openai/embeddingEndpoints.ts/0 | {
"file_path": "chat-ui/src/lib/server/embeddingEndpoints/openai/embeddingEndpoints.ts",
"repo_id": "chat-ui",
"token_count": 620
} |
import { buildPrompt } from "$lib/buildPrompt";
import { z } from "zod";
import type { Endpoint } from "../endpoints";
import type { TextGenerationStreamOutput } from "@huggingface/inference";
import { logger } from "$lib/server/logger";
export const endpointLangserveParametersSchema = z.object({
weight: z.number().i... | chat-ui/src/lib/server/endpoints/langserve/endpointLangserve.ts/0 | {
"file_path": "chat-ui/src/lib/server/endpoints/langserve/endpointLangserve.ts",
"repo_id": "chat-ui",
"token_count": 1394
} |
import { env } from "$env/dynamic/private";
import { generateFromDefaultEndpoint } from "$lib/server/generateFromDefaultEndpoint";
import type { EndpointMessage } from "../endpoints/endpoints";
import { logger } from "$lib/server/logger";
import { MessageUpdateType, type MessageUpdate } from "$lib/types/MessageUpdate";... | chat-ui/src/lib/server/textGeneration/title.ts/0 | {
"file_path": "chat-ui/src/lib/server/textGeneration/title.ts",
"repo_id": "chat-ui",
"token_count": 1069
} |
/* eslint-disable-next-line no-shadow */
export enum MarkdownElementType {
Header = "HEADER",
Paragraph = "PARAGRAPH",
BlockQuote = "BLOCKQUOTE",
CodeBlock = "CODE_BLOCK",
UnorderedList = "UNORDERED_LIST",
OrderedList = "ORDERED_LIST",
UnorderedListItem = "UNORDERED_LIST_ITEM",
OrderedListItem = "ORDERED_LIST_... | chat-ui/src/lib/server/websearch/markdown/types.ts/0 | {
"file_path": "chat-ui/src/lib/server/websearch/markdown/types.ts",
"repo_id": "chat-ui",
"token_count": 541
} |
import { JSDOM, VirtualConsole } from "jsdom";
import { isURL } from "$lib/utils/isUrl";
import type { WebSearchSource } from "$lib/types/WebSearch";
export default async function searchWebLocal(query: string): Promise<WebSearchSource[]> {
const abortController = new AbortController();
setTimeout(() => abortControll... | chat-ui/src/lib/server/websearch/search/endpoints/webLocal.ts/0 | {
"file_path": "chat-ui/src/lib/server/websearch/search/endpoints/webLocal.ts",
"repo_id": "chat-ui",
"token_count": 439
} |
import type { Timestamps } from "./Timestamps";
import type { Assistant } from "./Assistant";
export interface AssistantStats extends Timestamps {
assistantId: Assistant["_id"];
date: {
at: Date;
span: "hour";
};
count: number;
}
| chat-ui/src/lib/types/AssistantStats.ts/0 | {
"file_path": "chat-ui/src/lib/types/AssistantStats.ts",
"repo_id": "chat-ui",
"token_count": 80
} |
import type { Model } from "$lib/types/Model";
import { AutoTokenizer, PreTrainedTokenizer } from "@huggingface/transformers";
export async function getTokenizer(_modelTokenizer: Exclude<Model["tokenizer"], undefined>) {
if (typeof _modelTokenizer === "string") {
// return auto tokenizer
return await AutoTokenize... | chat-ui/src/lib/utils/getTokenizer.ts/0 | {
"file_path": "chat-ui/src/lib/utils/getTokenizer.ts",
"repo_id": "chat-ui",
"token_count": 229
} |
import type { Message } from "$lib/types/Message";
import Handlebars from "handlebars";
Handlebars.registerHelper("ifUser", function (this: Pick<Message, "from" | "content">, options) {
if (this.from == "user") return options.fn(this);
});
Handlebars.registerHelper(
"ifAssistant",
function (this: Pick<Message, "fr... | chat-ui/src/lib/utils/template.ts/0 | {
"file_path": "chat-ui/src/lib/utils/template.ts",
"repo_id": "chat-ui",
"token_count": 266
} |
import type { LayoutServerLoad } from "./$types";
import { collections } from "$lib/server/database";
import type { Conversation } from "$lib/types/Conversation";
import { UrlDependency } from "$lib/types/UrlDependency";
import { defaultModel, models, oldModels, validateModel } from "$lib/server/models";
import { authC... | chat-ui/src/routes/+layout.server.ts/0 | {
"file_path": "chat-ui/src/routes/+layout.server.ts",
"repo_id": "chat-ui",
"token_count": 3689
} |
<script lang="ts">
import { page } from "$app/state";
import { base } from "$app/paths";
import { goto } from "$app/navigation";
import { onMount } from "svelte";
import { env as envPublic } from "$env/dynamic/public";
import ChatWindow from "$lib/components/chat/ChatWindow.svelte";
import { findCurrentModel } f... | chat-ui/src/routes/assistant/[assistantId]/+page.svelte/0 | {
"file_path": "chat-ui/src/routes/assistant/[assistantId]/+page.svelte",
"repo_id": "chat-ui",
"token_count": 970
} |
import { redirect } from "@sveltejs/kit";
import { getOIDCAuthorizationUrl } from "$lib/server/auth";
import { base } from "$app/paths";
import { env } from "$env/dynamic/private";
export const actions = {
async default({ url, locals, request }) {
const referer = request.headers.get("referer");
let redirectURI = ... | chat-ui/src/routes/login/+page.server.ts/0 | {
"file_path": "chat-ui/src/routes/login/+page.server.ts",
"repo_id": "chat-ui",
"token_count": 280
} |
import { base } from "$app/paths";
import { redirect } from "@sveltejs/kit";
export async function load({ parent, params }) {
const data = await parent();
const model = data.models.find((m: { id: string }) => m.id === params.model);
if (!model || model.unlisted) {
redirect(302, `${base}/settings`);
}
return ... | chat-ui/src/routes/settings/(nav)/[...model]/+page.ts/0 | {
"file_path": "chat-ui/src/routes/settings/(nav)/[...model]/+page.ts",
"repo_id": "chat-ui",
"token_count": 111
} |
<script lang="ts">
import {
ToolOutputComponents,
type CommunityToolEditable,
type ToolInput,
} from "$lib/types/Tool";
import { createEventDispatcher, onMount } from "svelte";
import { browser } from "$app/environment";
import ToolLogo from "$lib/components/ToolLogo.svelte";
import { colors, icons } from "... | chat-ui/src/routes/tools/ToolEdit.svelte/0 | {
"file_path": "chat-ui/src/routes/tools/ToolEdit.svelte",
"repo_id": "chat-ui",
"token_count": 10200
} |
import timeit
import numpy as np
import datasets
from datasets.arrow_writer import ArrowWriter
from datasets.features.features import _ArrayXD
def get_duration(func):
def wrapper(*args, **kwargs):
starttime = timeit.default_timer()
_ = func(*args, **kwargs)
delta = timeit.default_timer()... | datasets/benchmarks/utils.py/0 | {
"file_path": "datasets/benchmarks/utils.py",
"repo_id": "datasets",
"token_count": 927
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.