text stringlengths 7 328k | id stringlengths 14 166 | metadata dict | __index_level_0__ int64 0 459 |
|---|---|---|---|
# coding=utf-8
# 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 requir... | transformers/tests/models/bloom/test_modeling_bloom.py/0 | {
"file_path": "transformers/tests/models/bloom/test_modeling_bloom.py",
"repo_id": "transformers",
"token_count": 16982
} | 387 |
# coding=utf-8
# Copyright 2021 Google AI and 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 ... | transformers/tests/models/canine/test_tokenization_canine.py/0 | {
"file_path": "transformers/tests/models/canine/test_tokenization_canine.py",
"repo_id": "transformers",
"token_count": 7154
} | 388 |
# coding=utf-8
# Copyright 2022 The OpenBMB Team 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/LIC... | transformers/tests/models/cpmant/test_modeling_cpmant.py/0 | {
"file_path": "transformers/tests/models/cpmant/test_modeling_cpmant.py",
"repo_id": "transformers",
"token_count": 4461
} | 389 |
# 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/deberta/test_modeling_tf_deberta.py/0 | {
"file_path": "transformers/tests/models/deberta/test_modeling_tf_deberta.py",
"repo_id": "transformers",
"token_count": 4967
} | 390 |
# coding=utf-8
# 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 r... | transformers/tests/models/depth_anything/test_modeling_depth_anything.py/0 | {
"file_path": "transformers/tests/models/depth_anything/test_modeling_depth_anything.py",
"repo_id": "transformers",
"token_count": 3846
} | 391 |
# 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/models/efficientformer/test_image_processing_efficientformer.py/0 | {
"file_path": "transformers/tests/models/efficientformer/test_image_processing_efficientformer.py",
"repo_id": "transformers",
"token_count": 1379
} | 392 |
# coding=utf-8
# 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 ag... | transformers/tests/models/glpn/test_image_processing_glpn.py/0 | {
"file_path": "transformers/tests/models/glpn/test_image_processing_glpn.py",
"repo_id": "transformers",
"token_count": 2610
} | 393 |
# 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/gpt_neox_japanese/test_modeling_gpt_neox_japanese.py/0 | {
"file_path": "transformers/tests/models/gpt_neox_japanese/test_modeling_gpt_neox_japanese.py",
"repo_id": "transformers",
"token_count": 4859
} | 394 |
# 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/maskformer/test_modeling_maskformer_swin.py/0 | {
"file_path": "transformers/tests/models/maskformer/test_modeling_maskformer_swin.py",
"repo_id": "transformers",
"token_count": 8052
} | 395 |
# 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/mgp_str/test_processor_mgp_str.py/0 | {
"file_path": "transformers/tests/models/mgp_str/test_processor_mgp_str.py",
"repo_id": "transformers",
"token_count": 3186
} | 396 |
# 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/mra/test_modeling_mra.py/0 | {
"file_path": "transformers/tests/models/mra/test_modeling_mra.py",
"repo_id": "transformers",
"token_count": 7571
} | 397 |
# 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/nat/test_modeling_nat.py/0 | {
"file_path": "transformers/tests/models/nat/test_modeling_nat.py",
"repo_id": "transformers",
"token_count": 6241
} | 398 |
# coding=utf-8
# Copyright 2023 IBM and 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
#
# Unle... | transformers/tests/models/patchtsmixer/test_modeling_patchtsmixer.py/0 | {
"file_path": "transformers/tests/models/patchtsmixer/test_modeling_patchtsmixer.py",
"repo_id": "transformers",
"token_count": 20454
} | 399 |
# coding=utf-8
# Copyright 2023 Microsoft and the HuggingFace Inc. team. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.... | transformers/tests/models/phi/test_modeling_phi.py/0 | {
"file_path": "transformers/tests/models/phi/test_modeling_phi.py",
"repo_id": "transformers",
"token_count": 9169
} | 400 |
# 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/pop2piano/test_processor_pop2piano.py/0 | {
"file_path": "transformers/tests/models/pop2piano/test_processor_pop2piano.py",
"repo_id": "transformers",
"token_count": 4029
} | 401 |
# coding=utf-8
# 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 r... | transformers/tests/models/rag/test_modeling_rag.py/0 | {
"file_path": "transformers/tests/models/rag/test_modeling_rag.py",
"repo_id": "transformers",
"token_count": 21862
} | 402 |
# 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/rembert/test_modeling_rembert.py/0 | {
"file_path": "transformers/tests/models/rembert/test_modeling_rembert.py",
"repo_id": "transformers",
"token_count": 9297
} | 403 |
# 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/seamless_m4t/test_modeling_seamless_m4t.py/0 | {
"file_path": "transformers/tests/models/seamless_m4t/test_modeling_seamless_m4t.py",
"repo_id": "transformers",
"token_count": 21929
} | 404 |
# 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/superpoint/test_modeling_superpoint.py/0 | {
"file_path": "transformers/tests/models/superpoint/test_modeling_superpoint.py",
"repo_id": "transformers",
"token_count": 5369
} | 405 |
# coding=utf-8
# Copyright 2018 Google T5 Authors and 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 requ... | transformers/tests/models/t5/test_modeling_tf_t5.py/0 | {
"file_path": "transformers/tests/models/t5/test_modeling_tf_t5.py",
"repo_id": "transformers",
"token_count": 21625
} | 406 |
# coding=utf-8
# Copyright 2021 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 law... | transformers/tests/models/vision_encoder_decoder/test_modeling_flax_vision_encoder_decoder.py/0 | {
"file_path": "transformers/tests/models/vision_encoder_decoder/test_modeling_flax_vision_encoder_decoder.py",
"repo_id": "transformers",
"token_count": 9445
} | 407 |
# 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/vit_hybrid/test_modeling_vit_hybrid.py/0 | {
"file_path": "transformers/tests/models/vit_hybrid/test_modeling_vit_hybrid.py",
"repo_id": "transformers",
"token_count": 4698
} | 408 |
# 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_with_lm/test_processor_wav2vec2_with_lm.py/0 | {
"file_path": "transformers/tests/models/wav2vec2_with_lm/test_processor_wav2vec2_with_lm.py",
"repo_id": "transformers",
"token_count": 8780
} | 409 |
# 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/tests/models/xglm/test_tokenization_xglm.py/0 | {
"file_path": "transformers/tests/models/xglm/test_tokenization_xglm.py",
"repo_id": "transformers",
"token_count": 4221
} | 410 |
# Copyright 2020 The HuggingFace Team. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicabl... | transformers/tests/pipelines/test_pipelines_table_question_answering.py/0 | {
"file_path": "transformers/tests/pipelines/test_pipelines_table_question_answering.py",
"repo_id": "transformers",
"token_count": 14810
} | 411 |
# coding=utf-8
# 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 requir... | transformers/tests/quantization/autoawq/test_awq.py/0 | {
"file_path": "transformers/tests/quantization/autoawq/test_awq.py",
"repo_id": "transformers",
"token_count": 8024
} | 412 |
# we define a fixture function below and it will be "used" by
# referencing its name from tests
import os
import pytest
from attr import dataclass
os.environ["AWS_DEFAULT_REGION"] = "us-east-1" # defaults region
@dataclass
class SageMakerTestEnvironment:
framework: str
role = "arn:aws:iam::558105141721:r... | transformers/tests/sagemaker/conftest.py/0 | {
"file_path": "transformers/tests/sagemaker/conftest.py",
"repo_id": "transformers",
"token_count": 1035
} | 413 |
# coding=utf-8
# Copyright 2023 HuggingFace Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or ag... | transformers/tests/test_image_processing_common.py/0 | {
"file_path": "transformers/tests/test_image_processing_common.py",
"repo_id": "transformers",
"token_count": 6780
} | 414 |
# coding=utf-8
# Copyright 2018 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 a... | transformers/tests/tokenization/test_tokenization_utils.py/0 | {
"file_path": "transformers/tests/tokenization/test_tokenization_utils.py",
"repo_id": "transformers",
"token_count": 5644
} | 415 |
# 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/trainer/test_data_collator.py/0 | {
"file_path": "transformers/tests/trainer/test_data_collator.py",
"repo_id": "transformers",
"token_count": 19982
} | 416 |
# 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
} | 417 |
# coding=utf-8
# Copyright 2023 The HuggingFace Inc. team.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable... | transformers/utils/check_build.py/0 | {
"file_path": "transformers/utils/check_build.py",
"repo_id": "transformers",
"token_count": 616
} | 418 |
# 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/utils/create_dummy_models.py/0 | {
"file_path": "transformers/utils/create_dummy_models.py",
"repo_id": "transformers",
"token_count": 28790
} | 419 |
# coding=utf-8
# Copyright 2022 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/sort_auto_mappings.py/0 | {
"file_path": "transformers/utils/sort_auto_mappings.py",
"repo_id": "transformers",
"token_count": 1812
} | 420 |
# pip install openrlbenchmark==0.2.1a5
# see https://github.com/openrlbenchmark/openrlbenchmark#get-started for documentation
echo "we deal with $TAGS_STRING"
python -m openrlbenchmark.rlops_multi_metrics \
--filters '?we=huggingface&wpn=trl&xaxis=_step&ceik=trl_ppo_trainer_config.value.reward_model&cen=trl_ppo_tr... | trl/benchmark/benchmark_level2_plot.sh/0 | {
"file_path": "trl/benchmark/benchmark_level2_plot.sh",
"repo_id": "trl",
"token_count": 632
} | 421 |
# Denoising Diffusion Policy Optimization
## The why
| Before | After DDPO finetuning |
| --- | --- |
| <div style="text-align: center"><img src="https://huggingface.co/datasets/trl-internal-testing/example-images/resolve/main/images/pre_squirrel.png"/></div> | <div style="text-align: center"><img src="https://huggin... | trl/docs/source/ddpo_trainer.mdx/0 | {
"file_path": "trl/docs/source/ddpo_trainer.mdx",
"repo_id": "trl",
"token_count": 2407
} | 422 |
# Reward Modeling
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_modeling.py`](https://github.com/huggingface/trl/tree/main/examples/scripts/reward_modeling.py).
## Expected dataset format
The [... | trl/docs/source/reward_trainer.mdx/0 | {
"file_path": "trl/docs/source/reward_trainer.mdx",
"repo_id": "trl",
"token_count": 877
} | 423 |
import multiprocessing
from dataclasses import dataclass, field
from typing import Optional
from datasets import load_dataset
from transformers import AutoTokenizer, HfArgumentParser
"""
python -i examples/datasets/tokenize_ds.py --debug --model HuggingFaceH4/zephyr-7b-beta
python -i examples/datasets/tokenize_ds.py... | trl/examples/datasets/tokenize_ds.py/0 | {
"file_path": "trl/examples/datasets/tokenize_ds.py",
"repo_id": "trl",
"token_count": 598
} | 424 |
# 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... | trl/examples/research_projects/tools/calculator.py/0 | {
"file_path": "trl/examples/research_projects/tools/calculator.py",
"repo_id": "trl",
"token_count": 1433
} | 425 |
# Copyright 2023 metric-space, 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 require... | trl/tests/test_ddpo_trainer.py/0 | {
"file_path": "trl/tests/test_ddpo_trainer.py",
"repo_id": "trl",
"token_count": 1784
} | 426 |
# This file is a copy of trl/examples/scripts/sft.py so that we could
# use it together with rich and the TRL CLI in a more customizable manner.
# 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 comp... | trl/trl/commands/cli.py/0 | {
"file_path": "trl/trl/commands/cli.py",
"repo_id": "trl",
"token_count": 888
} | 427 |
# 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... | trl/trl/trainer/base.py/0 | {
"file_path": "trl/trl/trainer/base.py",
"repo_id": "trl",
"token_count": 538
} | 428 |
<!--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/basic_tutorials/install.md/0 | {
"file_path": "accelerate/docs/source/basic_tutorials/install.md",
"repo_id": "accelerate",
"token_count": 996
} | 0 |
<!--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/index.md/0 | {
"file_path": "accelerate/docs/source/index.md",
"repo_id": "accelerate",
"token_count": 1371
} | 1 |
<!--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/big_modeling.md/0 | {
"file_path": "accelerate/docs/source/usage_guides/big_modeling.md",
"repo_id": "accelerate",
"token_count": 1766
} | 2 |
<!--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/training_zoo.md/0 | {
"file_path": "accelerate/docs/source/usage_guides/training_zoo.md",
"repo_id": "accelerate",
"token_count": 5980
} | 3 |
# 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... | accelerate/examples/complete_nlp_example.py/0 | {
"file_path": "accelerate/examples/complete_nlp_example.py",
"repo_id": "accelerate",
"token_count": 5046
} | 4 |
#!/bin/bash
#SBATCH --job-name=multigpu
#SBATCH -D .
#SBATCH --output=O-%x.%j
#SBATCH --error=E-%x.%j
#SBATCH --nodes=1
#SBATCH --ntasks-per-node=1 # number of MP tasks
#SBATCH --gres=gpu:4 # number of GPUs per node
#SBATCH --cpus-per-task=160 # number of cores per tasks
#SBATCH --time=0... | accelerate/examples/slurm/submit_multigpu.sh/0 | {
"file_path": "accelerate/examples/slurm/submit_multigpu.sh",
"repo_id": "accelerate",
"token_count": 326
} | 5 |
#!/usr/bin/env python
# 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
#
# Unles... | accelerate/src/accelerate/commands/config/cluster.py/0 | {
"file_path": "accelerate/src/accelerate/commands/config/cluster.py",
"repo_id": "accelerate",
"token_count": 15513
} | 6 |
#!/usr/bin/env python
# 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
#
# Unles... | accelerate/src/accelerate/commands/test.py/0 | {
"file_path": "accelerate/src/accelerate/commands/test.py",
"repo_id": "accelerate",
"token_count": 755
} | 7 |
# 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/utils/bnb.py/0 | {
"file_path": "accelerate/src/accelerate/utils/bnb.py",
"repo_id": "accelerate",
"token_count": 8764
} | 8 |
# 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/torch_xla.py/0 | {
"file_path": "accelerate/src/accelerate/utils/torch_xla.py",
"repo_id": "accelerate",
"token_count": 691
} | 9 |
compute_environment: LOCAL_MACHINE
deepspeed_config: {}
distributed_type: 'NO'
downcast_bf16: 'no'
fsdp_config: {}
gpu_ids: all
machine_rank: 0
main_process_ip: null
main_process_port: null
main_training_function: main
megatron_lm_config: {}
mixed_precision: 'no'
num_machines: 1
num_processes: 1
rdzv_backend: static
sa... | accelerate/tests/test_configs/latest.yaml/0 | {
"file_path": "accelerate/tests/test_configs/latest.yaml",
"repo_id": "accelerate",
"token_count": 186
} | 10 |
# Model arguments
model_name_or_path: HuggingFaceH4/starchat2-15b-sft-v0.1
torch_dtype: bfloat16
# Data training arguments
# For definitions, see: src/h4/training/config.py
dataset_mixer:
HuggingFaceH4/ultrafeedback_binarized: 1.0
HuggingFaceH4/orca_dpo_pairs: 1.0
dataset_splits:
- train_prefs
- test_prefs
preproc... | alignment-handbook/recipes/starchat2-15b/dpo/config_v0.1.yaml/0 | {
"file_path": "alignment-handbook/recipes/starchat2-15b/dpo/config_v0.1.yaml",
"repo_id": "alignment-handbook",
"token_count": 399
} | 11 |
__version__ = "0.3.0.dev0"
from .configs import DataArguments, DPOConfig, H4ArgumentParser, ModelArguments, SFTConfig
from .data import apply_chat_template, get_datasets
from .decontaminate import decontaminate_humaneval
from .model_utils import (
get_checkpoint,
get_kbit_device_map,
get_peft_config,
g... | alignment-handbook/src/alignment/__init__.py/0 | {
"file_path": "alignment-handbook/src/alignment/__init__.py",
"repo_id": "alignment-handbook",
"token_count": 148
} | 12 |
# Creating a desktop Tauri app
| candle/candle-book/src/apps/desktop.md/0 | {
"file_path": "candle/candle-book/src/apps/desktop.md",
"repo_id": "candle",
"token_count": 8
} | 13 |
#[cfg(test)]
pub mod simplified;
#[cfg(test)]
mod tests {
use anyhow::Result;
use candle::{DType, Device, Tensor};
use parquet::file::reader::SerializedFileReader;
// NOTE: Waiting on https://github.com/rust-lang/mdBook/pull/1856
#[rustfmt::skip]
#[tokio::test]
async fn book_hub_1() {
// A... | candle/candle-book/src/lib.rs/0 | {
"file_path": "candle/candle-book/src/lib.rs",
"repo_id": "candle",
"token_count": 2806
} | 14 |
#[cfg(feature = "mkl")]
extern crate intel_mkl_src;
#[cfg(feature = "accelerate")]
extern crate accelerate_src;
use anyhow::Result;
use candle_core::{Device, Tensor};
fn main() -> Result<()> {
let a = Tensor::new(&[[0.0f32, 1.0, 2.0], [3.0, 4.0, 5.0]], &Device::Cpu)?;
let b = Tensor::new(&[[88.0f32, 99.0]], ... | candle/candle-core/examples/basics.rs/0 | {
"file_path": "candle/candle-core/examples/basics.rs",
"repo_id": "candle",
"token_count": 287
} | 15 |
use crate::backend::{BackendDevice, BackendStorage};
use crate::op::{BinaryOpT, CmpOp, ReduceOp, UnaryOpT};
use crate::{CpuStorage, DType, Layout, Result, Shape, WithDType};
pub use candle_kernels as kernels;
pub use cudarc;
use cudarc::cublas::{Gemm, GemmConfig, StridedBatchedConfig};
use cudarc::driver::{
CudaFun... | candle/candle-core/src/cuda_backend.rs/0 | {
"file_path": "candle/candle-core/src/cuda_backend.rs",
"repo_id": "candle",
"token_count": 47475
} | 16 |
use super::k_quants::{
BlockQ2K, BlockQ3K, BlockQ4K, BlockQ4_0, BlockQ5K, BlockQ6K, BlockQ8K, BlockQ8_0, QK8_0, QK_K,
};
use crate::Result;
use byteorder::{ByteOrder, LittleEndian};
use half::f16;
#[cfg(target_arch = "x86")]
use core::arch::x86::*;
#[cfg(target_arch = "x86_64")]
use core::arch::x86_64::*;
#[inlin... | candle/candle-core/src/quantized/avx.rs/0 | {
"file_path": "candle/candle-core/src/quantized/avx.rs",
"repo_id": "candle",
"token_count": 17495
} | 17 |
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": 1148
} | 18 |
/// Regression test for pth files not loading on Windows.
#[test]
fn test_pth() {
let tensors = candle_core::pickle::PthTensors::new("tests/test.pt", None).unwrap();
tensors.get("test").unwrap().unwrap();
}
#[test]
fn test_pth_with_key() {
let tensors =
candle_core::pickle::PthTensors::new("tests/t... | candle/candle-core/tests/pth_tests.rs/0 | {
"file_path": "candle/candle-core/tests/pth_tests.rs",
"repo_id": "candle",
"token_count": 440
} | 19 |
//! The MNIST hand-written digit dataset.
//!
//! The files can be obtained from the following link:
//! <http://yann.lecun.com/exdb/mnist/>
use candle::{DType, Device, Error, Result, Tensor};
use hf_hub::{api::sync::Api, Repo, RepoType};
use parquet::file::reader::{FileReader, SerializedFileReader};
use std::fs::File;... | candle/candle-datasets/src/vision/mnist.rs/0 | {
"file_path": "candle/candle-datasets/src/vision/mnist.rs",
"repo_id": "candle",
"token_count": 2129
} | 20 |
#include <stdint.h>
#include "reduction_utils.cuh"
template <typename scalar_t>
__device__ void
rms_norm_kernel(scalar_t *__restrict__ out, // [num_tokens, hidden_size]
const scalar_t *__restrict__ input, // [num_tokens, hidden_size]
const float epsilon, const uint32_t num_token... | candle/candle-examples/examples/custom-ops/kernels/layernorm_kernels.cu/0 | {
"file_path": "candle/candle-examples/examples/custom-ops/kernels/layernorm_kernels.cu",
"repo_id": "candle",
"token_count": 561
} | 21 |
# candle-gemma: 2b and 7b LLMs from Google DeepMind
[Gemma](https://ai.google.dev/gemma/docs) is a collection of lightweight open
models published by Google Deepmind with a 2b and a 7b variant.
In order to use the example below, you have to accept the license on the
[HuggingFace Hub Gemma repo](https://huggingface.co... | candle/candle-examples/examples/gemma/README.md/0 | {
"file_path": "candle/candle-examples/examples/gemma/README.md",
"repo_id": "candle",
"token_count": 351
} | 22 |
#[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/marian-mt/main.rs/0 | {
"file_path": "candle/candle-examples/examples/marian-mt/main.rs",
"repo_id": "candle",
"token_count": 2385
} | 23 |
#[cfg(feature = "mkl")]
extern crate intel_mkl_src;
#[cfg(feature = "accelerate")]
extern crate accelerate_src;
use anyhow::{Error as E, Result};
use clap::{Parser, ValueEnum};
use candle_transformers::models::mixformer::{Config, MixFormerSequentialForCausalLM as MixFormer};
use candle_transformers::models::phi::{Co... | candle/candle-examples/examples/phi/main.rs/0 | {
"file_path": "candle/candle-examples/examples/phi/main.rs",
"repo_id": "candle",
"token_count": 8133
} | 24 |
#[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::mpt::{Config, Model as M};
use candle_transformers::models::quantized_mpt::Model as Q;
use candle::{DType, Device, Tens... | candle/candle-examples/examples/replit-code/main.rs/0 | {
"file_path": "candle/candle-examples/examples/replit-code/main.rs",
"repo_id": "candle",
"token_count": 3752
} | 25 |
# candle-stable-diffusion: A Diffusers API in Rust/Candle

_A rusty robot holding a fire torch in its hand_, generated by Stable Diffusion
XL using Rust and [candle](https://github.com/huggingface/candle).
The `stable-diffusion` example is a conversion... | candle/candle-examples/examples/stable-diffusion/README.md/0 | {
"file_path": "candle/candle-examples/examples/stable-diffusion/README.md",
"repo_id": "candle",
"token_count": 917
} | 26 |
#[cfg(feature = "mkl")]
extern crate intel_mkl_src;
#[cfg(feature = "accelerate")]
extern crate accelerate_src;
use candle_transformers::object_detection::{non_maximum_suppression, Bbox};
mod darknet;
use anyhow::Result;
use candle::{DType, Device, Tensor};
use candle_nn::{Module, VarBuilder};
use clap::Parser;
use ... | candle/candle-examples/examples/yolo-v3/main.rs/0 | {
"file_path": "candle/candle-examples/examples/yolo-v3/main.rs",
"repo_id": "candle",
"token_count": 3180
} | 27 |
[package]
name = "candle-flash-attn"
version = "0.4.2"
edition = "2021"
description = "Flash attention layer for the candle ML framework."
repository = "https://github.com/huggingface/candle"
keywords = ["blas", "tensor", "machine-learning"]
categories = ["science"]
license = "MIT OR Apache-2.0"
readme = "README.md"
... | candle/candle-flash-attn/Cargo.toml/0 | {
"file_path": "candle/candle-flash-attn/Cargo.toml",
"repo_id": "candle",
"token_count": 266
} | 28 |
mod ffi;
use candle::backend::BackendStorage;
use candle::cuda_backend::cudarc::driver::DevicePtr;
use candle::cuda_backend::WrapErr;
use candle::{CpuStorage, DType, Layout, Result, Shape, Tensor};
use half::{bf16, f16};
pub struct FlashAttn {
pub softmax_scale: f32,
pub alibi_slopes: Option<Tensor>,
pub ... | candle/candle-flash-attn/src/lib.rs/0 | {
"file_path": "candle/candle-flash-attn/src/lib.rs",
"repo_id": "candle",
"token_count": 15951
} | 29 |
#include "cuda_utils.cuh"
#include <cmath>
#include <stdint.h>
const int BLOCK_SIZE = 1024;
// TODO: Maybe add some fast_sum_f16_f32 variant that not only accumulate in f32
// but also expect a f32 output so that this can be used for normalization e.g.
// in softmax.
// Fast reduce sum kernel, this assumes that the ... | candle/candle-kernels/src/reduce.cu/0 | {
"file_path": "candle/candle-kernels/src/reduce.cu",
"repo_id": "candle",
"token_count": 8419
} | 30 |
use super::*;
use half::{bf16, f16};
use metal::MTLResourceOptions;
fn read_to_vec<T: Clone>(buffer: &Buffer, n: usize) -> Vec<T> {
let ptr = buffer.contents() as *const T;
assert!(!ptr.is_null());
let slice = unsafe { std::slice::from_raw_parts(ptr, n) };
slice.to_vec()
}
fn new_buffer<T>(device: &De... | candle/candle-metal-kernels/src/tests.rs/0 | {
"file_path": "candle/candle-metal-kernels/src/tests.rs",
"repo_id": "candle",
"token_count": 29021
} | 31 |
//! Group Normalization.
//!
//! This layer applies Group Normalization over a mini-batch of inputs.
use candle::{DType, Result, Tensor};
// This group norm version handles both weight and bias so removes the mean.
#[derive(Clone, Debug)]
pub struct GroupNorm {
weight: Tensor,
bias: Tensor,
eps: f64,
n... | candle/candle-nn/src/group_norm.rs/0 | {
"file_path": "candle/candle-nn/src/group_norm.rs",
"repo_id": "candle",
"token_count": 1372
} | 32 |
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
} | 33 |
fn main() {
pyo3_build_config::add_extension_module_link_args();
}
| candle/candle-pyo3/build.rs/0 | {
"file_path": "candle/candle-pyo3/build.rs",
"repo_id": "candle",
"token_count": 30
} | 34 |
import candle
from candle import Tensor
_UNSIGNED_DTYPES = set([str(candle.u8), str(candle.u32)])
def _assert_tensor_metadata(
actual: Tensor,
expected: Tensor,
check_device: bool = True,
check_dtype: bool = True,
check_layout: bool = True,
check_stride: bool = False,
):
if check_device:... | candle/candle-pyo3/py_src/candle/testing/__init__.py/0 | {
"file_path": "candle/candle-pyo3/py_src/candle/testing/__init__.py",
"repo_id": "candle",
"token_count": 854
} | 35 |
import candle
from candle import Tensor
from candle.testing import assert_equal, assert_almost_equal
import pytest
@pytest.mark.parametrize("dtype", [candle.f32, candle.f64, candle.f16, candle.u32, candle.u8, candle.i64])
def test_assert_equal_asserts_correctly(dtype: candle.DType):
a = Tensor([1, 2, 3]).to(dtype... | candle/candle-pyo3/tests/bindings/test_testing.py/0 | {
"file_path": "candle/candle-pyo3/tests/bindings/test_testing.py",
"repo_id": "candle",
"token_count": 476
} | 36 |
use super::with_tracing::{layer_norm, linear, LayerNorm, Linear};
use candle::{DType, Device, Result, Tensor};
use candle_nn::{Embedding, Module, VarBuilder};
use serde::Deserialize;
pub const DTYPE: DType = DType::F32;
fn masked_fill(on_false: &Tensor, mask: &Tensor, on_true: f32) -> Result<Tensor> {
let shape =... | candle/candle-transformers/src/models/distilbert.rs/0 | {
"file_path": "candle/candle-transformers/src/models/distilbert.rs",
"repo_id": "candle",
"token_count": 5381
} | 37 |
//! MobileOne inference implementation based on timm and candle-repvgg
//!
//! See "MobileOne: An Improved One millisecond Mobile Backbone"
//! https://arxiv.org/abs/2206.04040
use candle::{DType, Result, Tensor, D};
use candle_nn::{
batch_norm, conv2d, conv2d_no_bias, linear, ops::sigmoid, BatchNorm, Conv2d, Conv... | candle/candle-transformers/src/models/mobileone.rs/0 | {
"file_path": "candle/candle-transformers/src/models/mobileone.rs",
"repo_id": "candle",
"token_count": 4721
} | 38 |
// T5 Text Model, quantized version
// https://github.com/huggingface/transformers/blob/main/src/transformers/models/t5/modeling_t5.py
use crate::models::t5::{deserialize_feed_forward_proj_activation, ActivationWithOptionalGating};
use crate::models::with_tracing::QMatMul;
use crate::quantized_nn::Embedding;
pub use c... | candle/candle-transformers/src/models/quantized_t5.rs/0 | {
"file_path": "candle/candle-transformers/src/models/quantized_t5.rs",
"repo_id": "candle",
"token_count": 13996
} | 39 |
//! # Denoising Diffusion Implicit Models
//!
//! The Denoising Diffusion Implicit Models (DDIM) is a simple scheduler
//! similar to Denoising Diffusion Probabilistic Models (DDPM). The DDPM
//! generative process is the reverse of a Markovian process, DDIM generalizes
//! this to non-Markovian guidance.
//!
//! Denoi... | candle/candle-transformers/src/models/stable_diffusion/ddim.rs/0 | {
"file_path": "candle/candle-transformers/src/models/stable_diffusion/ddim.rs",
"repo_id": "candle",
"token_count": 3953
} | 40 |
use crate::models::with_tracing::{conv2d, linear, linear_no_bias, Conv2d, Linear};
use candle::{IndexOp, Module, Result, Tensor, D};
use candle_nn::{layer_norm, LayerNorm, VarBuilder};
// https://github.com/huggingface/transformers/blob/main/src/transformers/models/vit/configuration_vit.py
#[derive(Debug, Clone, serde... | candle/candle-transformers/src/models/vit.rs/0 | {
"file_path": "candle/candle-transformers/src/models/vit.rs",
"repo_id": "candle",
"token_count": 5870
} | 41 |
use candle::{DType, Device, IndexOp, Result, Tensor, D};
use candle_nn::{
embedding, linear_no_bias as linear, rms_norm, Embedding, Linear, Module, RmsNorm, VarBuilder,
};
use std::collections::HashMap;
use std::sync::{Arc, Mutex};
#[derive(Debug, Clone)]
pub struct Config {
pub dim: usize, // transform... | candle/candle-wasm-examples/llama2-c/src/model.rs/0 | {
"file_path": "candle/candle-wasm-examples/llama2-c/src/model.rs",
"repo_id": "candle",
"token_count": 5272
} | 42 |
use crate::console_log;
use crate::worker::{ModelData, Segment, Worker, WorkerInput, WorkerOutput};
use js_sys::Date;
use wasm_bindgen::prelude::*;
use wasm_bindgen_futures::JsFuture;
use yew::{html, Component, Context, Html};
use yew_agent::{Bridge, Bridged};
const SAMPLE_NAMES: [&str; 6] = [
"audios/samples_jfk.... | candle/candle-wasm-examples/whisper/src/app.rs/0 | {
"file_path": "candle/candle-wasm-examples/whisper/src/app.rs",
"repo_id": "candle",
"token_count": 5679
} | 43 |
use candle_wasm_example_yolo::coco_classes;
use candle_wasm_example_yolo::model::Bbox;
use candle_wasm_example_yolo::worker::Model as M;
use candle_wasm_example_yolo::worker::ModelPose as P;
use wasm_bindgen::prelude::*;
#[wasm_bindgen]
pub struct Model {
inner: M,
}
#[wasm_bindgen]
impl Model {
#[wasm_bindge... | candle/candle-wasm-examples/yolo/src/bin/m.rs/0 | {
"file_path": "candle/candle-wasm-examples/yolo/src/bin/m.rs",
"repo_id": "candle",
"token_count": 840
} | 44 |
# template used in production for HuggingChat.
MODELS=`[
{
"name" : "mistralai/Mixtral-8x7B-Instruct-v0.1",
"description" : "The latest MoE model from Mistral AI! 8x7B and outperforms Llama 2 70B in most benchmarks.",
"logoUrl": "https://huggingface.co/datasets/huggingchat/models-logo/resolve/main/mist... | chat-ui/.env.template/0 | {
"file_path": "chat-ui/.env.template",
"repo_id": "chat-ui",
"token_count": 5847
} | 45 |
import readline from "readline";
import minimist from "minimist";
// @ts-expect-error: vite-node makes the var available but the typescript compiler doesn't see them
import { MONGODB_URL } from "$env/static/private";
import { faker } from "@faker-js/faker";
import { ObjectId } from "mongodb";
import { collections } ... | chat-ui/scripts/populate.ts/0 | {
"file_path": "chat-ui/scripts/populate.ts",
"repo_id": "chat-ui",
"token_count": 3340
} | 46 |
<script lang="ts">
export let isCollapsed: boolean;
export let classNames: string;
</script>
<button
on:click
class="{classNames} group flex h-16 w-6 flex-col items-center justify-center -space-y-1 outline-none *:h-3 *:w-1 *:rounded-full *:hover:bg-gray-300 max-md:hidden dark:*:hover:bg-gray-600 {!isCollapsed
? ... | chat-ui/src/lib/components/ExpandNavigation.svelte/0 | {
"file_path": "chat-ui/src/lib/components/ExpandNavigation.svelte",
"repo_id": "chat-ui",
"token_count": 238
} | 47 |
<script lang="ts">
import { fade } from "svelte/transition";
import IconDazzled from "$lib/components/icons/IconDazzled.svelte";
export let message = "";
</script>
<div
transition:fade|global={{ duration: 300 }}
class="pointer-events-none fixed right-0 top-12 z-20 bg-gradient-to-bl from-red-500/20 via-red-500/0... | chat-ui/src/lib/components/Toast.svelte/0 | {
"file_path": "chat-ui/src/lib/components/Toast.svelte",
"repo_id": "chat-ui",
"token_count": 259
} | 48 |
<script lang="ts">
import { page } from "$app/stores";
import { PUBLIC_APP_ASSETS, PUBLIC_APP_NAME, PUBLIC_ORIGIN } from "$env/static/public";
import { base } from "$app/paths";
export let classNames = "";
</script>
{#if PUBLIC_APP_ASSETS === "chatui"}
<svg
height="30"
width="30"
viewBox="0 0 30 30"
xmln... | chat-ui/src/lib/components/icons/Logo.svelte/0 | {
"file_path": "chat-ui/src/lib/components/icons/Logo.svelte",
"repo_id": "chat-ui",
"token_count": 550
} | 49 |
import { z } from "zod";
import { ANTHROPIC_API_KEY } from "$env/static/private";
import type { Endpoint } from "../endpoints";
import type { TextGenerationStreamOutput } from "@huggingface/inference";
export const endpointAnthropicParametersSchema = z.object({
weight: z.number().int().positive().default(1),
model: ... | chat-ui/src/lib/server/endpoints/anthropic/endpointAnthropic.ts/0 | {
"file_path": "chat-ui/src/lib/server/endpoints/anthropic/endpointAnthropic.ts",
"repo_id": "chat-ui",
"token_count": 1031
} | 50 |
import { dot } from "@xenova/transformers";
import type { EmbeddingBackendModel } from "$lib/server/embeddingModels";
import type { Embedding } from "$lib/server/embeddingEndpoints/embeddingEndpoints";
// see here: https://github.com/nmslib/hnswlib/blob/359b2ba87358224963986f709e593d799064ace6/README.md?plain=1#L34
fu... | chat-ui/src/lib/server/sentenceSimilarity.ts/0 | {
"file_path": "chat-ui/src/lib/server/sentenceSimilarity.ts",
"repo_id": "chat-ui",
"token_count": 497
} | 51 |
import { writable } from "svelte/store";
export interface WebSearchParameters {
useSearch: boolean;
nItems: number;
}
export const webSearchParameters = writable<WebSearchParameters>({
useSearch: false,
nItems: 5,
});
| chat-ui/src/lib/stores/webSearchParameters.ts/0 | {
"file_path": "chat-ui/src/lib/stores/webSearchParameters.ts",
"repo_id": "chat-ui",
"token_count": 68
} | 52 |
import type { Conversation } from "./Conversation";
export type SharedConversation = Pick<
Conversation,
| "model"
| "embeddingModel"
| "title"
| "rootMessageId"
| "messages"
| "preprompt"
| "assistantId"
| "createdAt"
| "updatedAt"
> & {
_id: string;
hash: string;
};
| chat-ui/src/lib/types/SharedConversation.ts/0 | {
"file_path": "chat-ui/src/lib/types/SharedConversation.ts",
"repo_id": "chat-ui",
"token_count": 114
} | 53 |
import type { Conversation } from "$lib/types/Conversation";
import { sha256 } from "./sha256";
export async function hashConv(conv: Conversation) {
// messages contains the conversation message but only the immutable part
const messages = conv.messages.map((message) => {
return (({ from, id, content, webSearchId ... | chat-ui/src/lib/utils/hashConv.ts/0 | {
"file_path": "chat-ui/src/lib/utils/hashConv.ts",
"repo_id": "chat-ui",
"token_count": 132
} | 54 |
import { collections } from "$lib/server/database";
import { ObjectId } from "mongodb";
import { describe, expect, it } from "vitest";
import { insertLegacyConversation, insertSideBranchesConversation } from "./treeHelpers.spec";
import type { Message } from "$lib/types/Message";
import { addSibling } from "./addSibli... | chat-ui/src/lib/utils/tree/addSibling.spec.ts/0 | {
"file_path": "chat-ui/src/lib/utils/tree/addSibling.spec.ts",
"repo_id": "chat-ui",
"token_count": 950
} | 55 |
import { collections } from "$lib/server/database";
import { authCondition } from "$lib/server/auth";
import type { Conversation } from "$lib/types/Conversation";
export async function GET({ locals }) {
if (locals.user?._id || locals.sessionId) {
const convs = await collections.conversations
.find({
...authC... | chat-ui/src/routes/api/conversations/+server.ts/0 | {
"file_path": "chat-ui/src/routes/api/conversations/+server.ts",
"repo_id": "chat-ui",
"token_count": 298
} | 56 |
import { authCondition } from "$lib/server/auth";
import { collections } from "$lib/server/database";
import type { SharedConversation } from "$lib/types/SharedConversation";
import { getShareUrl } from "$lib/utils/getShareUrl";
import { hashConv } from "$lib/utils/hashConv";
import { error } from "@sveltejs/kit";
impo... | chat-ui/src/routes/conversation/[id]/share/+server.ts/0 | {
"file_path": "chat-ui/src/routes/conversation/[id]/share/+server.ts",
"repo_id": "chat-ui",
"token_count": 761
} | 57 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.