Search is not available for this dataset
repo stringlengths 2 152 ⌀ | file stringlengths 15 239 | code stringlengths 0 58.4M | file_length int64 0 58.4M | avg_line_length float64 0 1.81M | max_line_length int64 0 12.7M | extension_type stringclasses 364
values |
|---|---|---|---|---|---|---|
null | ParlAI-main/parlai/agents/bart/convert_fairseq_to_parlai.py | #!/usr/bin/env python3
# Copyright (c) Facebook, Inc. and its affiliates.
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
"""
A script for converting a fairseq model to ParlAI model.
Specifically works for transformer-based models.
Example ... | 18,448 | 36.270707 | 110 | py |
null | ParlAI-main/parlai/agents/bart/modules.py | #!/usr/bin/env python3
# Copyright (c) Facebook, Inc. and its affiliates.
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
"""
BART Module.
"""
import torch
import torch.nn.functional as F
from typing import Any, Dict, Union, List, Optional
from... | 2,824 | 31.471264 | 86 | py |
null | ParlAI-main/parlai/agents/bert_classifier/README.md | # BERT Classifier
This directory contains an implementations of a classifier based on a pretrained language model BERT (Devlin et al. https://arxiv.org/abs/1810.04805).
It relies on the pytorch implementation provided by Hugging Face (https://github.com/huggingface/pytorch-pretrained-BERT).
## Basic Examples
Train ... | 799 | 49 | 243 | md |
null | ParlAI-main/parlai/agents/bert_classifier/__init__.py | #!/usr/bin/env python3
# Copyright (c) Facebook, Inc. and its affiliates.
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
| 198 | 38.8 | 65 | py |
null | ParlAI-main/parlai/agents/bert_classifier/bert_classifier.py | #!/usr/bin/env python3
# Copyright (c) Facebook, Inc. and its affiliates.
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
"""
BERT classifier agent uses bert embeddings to make an utterance-level classification.
This implementation allows to... | 8,642 | 33.991903 | 140 | py |
null | ParlAI-main/parlai/agents/bert_ranker/README.md | # BERT Ranker
This directory contains several implementations of a ranker based on a pretrained language model BERT (Devlin et al. https://arxiv.org/abs/1810.04805). It relies on the pytorch implementation provided by Hugging Face (https://github.com/huggingface/pytorch-pretrained-BERT).
## Content
This directory co... | 1,814 | 63.821429 | 274 | md |
null | ParlAI-main/parlai/agents/bert_ranker/__init__.py | 0 | 0 | 0 | py | |
null | ParlAI-main/parlai/agents/bert_ranker/bert_dictionary.py | #!/usr/bin/env python3
# Copyright (c) Facebook, Inc. and its affiliates.
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
from parlai.core.dict import DictionaryAgent
from parlai.utils.io import PathManager
from parlai.utils.misc import warn_o... | 2,599 | 32.333333 | 93 | py |
null | ParlAI-main/parlai/agents/bert_ranker/bert_ranker.py | #!/usr/bin/env python3
# Copyright (c) Facebook, Inc. and its affiliates.
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
from .bi_encoder_ranker import BiEncoderRankerAgent # NOQA
from .cross_encoder_ranker import CrossEncoderRankerAgent # ... | 840 | 34.041667 | 65 | py |
null | ParlAI-main/parlai/agents/bert_ranker/bi_encoder_ranker.py | #!/usr/bin/env python3
# Copyright (c) Facebook, Inc. and its affiliates.
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
from typing import Optional
from parlai.core.params import ParlaiParser
from parlai.core.opt import Opt
from parlai.core.... | 10,030 | 35.74359 | 88 | py |
null | ParlAI-main/parlai/agents/bert_ranker/both_encoder_ranker.py | #!/usr/bin/env python3
# Copyright (c) Facebook, Inc. and its affiliates.
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
from typing import Optional
from parlai.core.params import ParlaiParser
from parlai.core.opt import Opt
from .bert_dictio... | 5,336 | 37.673913 | 87 | py |
null | ParlAI-main/parlai/agents/bert_ranker/cross_encoder_ranker.py | #!/usr/bin/env python3
# Copyright (c) Facebook, Inc. and its affiliates.
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
from typing import Optional
from parlai.core.params import ParlaiParser
from parlai.core.opt import Opt
from parlai.utils... | 3,421 | 32.54902 | 83 | py |
null | ParlAI-main/parlai/agents/bert_ranker/helpers.py | #!/usr/bin/env python3
# Copyright (c) Facebook, Inc. and its affiliates.
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
"""
BERT helpers.
"""
from parlai.core.torch_ranker_agent import TorchRankerAgent
from parlai.utils.torch import neginf... | 7,284 | 36.942708 | 143 | py |
null | ParlAI-main/parlai/agents/examples/README.md | # Examples
Contains example agents and models.
## Basic Examples
Train an example generator model, described in the tutorial in `docs/source/tutorial_torch_generator_agent.md`:
```
parlai train_model -m examples/seq2seq \
-mf /tmp/example_model \
-t convai2 -bs 32 -eps 2 --truncate 128
```
Train an examp... | 535 | 25.8 | 111 | md |
null | ParlAI-main/parlai/agents/examples/__init__.py | #!/usr/bin/env python3
# Copyright (c) Facebook, Inc. and its affiliates.
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
| 199 | 32.333333 | 65 | py |
null | ParlAI-main/parlai/agents/examples/seq2seq.py | #!/usr/bin/env python3
# Copyright (c) Facebook, Inc. and its affiliates.
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
r"""
Example TorchGeneratorAgent model.
This demonstrates the minimal structure of a building a generative model, consi... | 7,495 | 32.918552 | 88 | py |
null | ParlAI-main/parlai/agents/examples/tra.py | #!/usr/bin/env python3
# Copyright (c) Facebook, Inc. and its affiliates.
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
"""
This is an example how to extend torch ranker agent and use it for your own purpose.
In this example, we will just ... | 3,572 | 35.459184 | 87 | py |
null | ParlAI-main/parlai/agents/examples/transformer_variant.py | #!/usr/bin/env python3
# Copyright (c) Facebook, Inc. and its affiliates.
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
"""
Example code for specifying custom transformer variants.
TransformerVariantAgent:
- Minimal changes needed to:
- ... | 6,891 | 32.619512 | 99 | py |
null | ParlAI-main/parlai/agents/fid/README.md | # Fusion in Decoder (FiD)
The FiD model is first described in [Leveraging Passage Retrieval with Generative Models for Open Domain Question Answering](https://arxiv.org/abs/2007.01282) (G. Izacard, E. Grave 2020); the original implementation can be found [here](https://github.com/facebookresearch/FiD). The implementat... | 702 | 116.166667 | 604 | md |
null | ParlAI-main/parlai/agents/fid/__init__.py | #!/usr/bin/env python3
# Copyright (c) Facebook, Inc. and its affiliates.
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
| 199 | 32.333333 | 65 | py |
null | ParlAI-main/parlai/agents/fid/fid.py | #!/usr/bin/env python3
# Copyright (c) Facebook, Inc. and its affiliates.
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
"""
Leveraging Passage Retrieval with Generative Models for Open Domain Question Answering.
See https://arxiv.org/abs/20... | 18,942 | 35.782524 | 143 | py |
null | ParlAI-main/parlai/agents/fixed_response/README.md | # Fixed Response
This is an agent that simply always outputs the given fixed response.
Good for debugging purposes or as a baseline, e.g. if always predicting a given class.
## Basic Examples
Evaluate on the dialogue safety task, always predicting __notok__
```bash
parlai eval_model -t dialogue_safety -dt valid -m ... | 353 | 28.5 | 86 | md |
null | ParlAI-main/parlai/agents/fixed_response/__init__.py | #!/usr/bin/env python3
# Copyright (c) Facebook, Inc. and its affiliates.
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
| 199 | 32.333333 | 65 | py |
null | ParlAI-main/parlai/agents/fixed_response/fixed_response.py | #!/usr/bin/env python3
# Copyright (c) Facebook, Inc. and its affiliates.
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
"""
Simple agent which always outputs the given fixed response.
Good for debugging purposes or as a baseline, e.g. if al... | 1,320 | 29.72093 | 86 | py |
null | ParlAI-main/parlai/agents/gpt3/README.md | # GPT3
This is an agent that interfaces with [OpenAI's completion V1 api](https://platform.openai.com/docs/api-reference/completions) (/v1/completions). The completions v1 API broadly covers the models that fall under GPT-3 like:
* text-davinci-003
* text-curie-001
* text-ada-001
The model works by prompting the compl... | 2,277 | 55.95 | 388 | md |
null | ParlAI-main/parlai/agents/gpt3/__init__.py | #!/usr/bin/env python3
# Copyright (c) Facebook, Inc. and its affiliates.
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
| 199 | 32.333333 | 65 | py |
null | ParlAI-main/parlai/agents/gpt3/gpt3.py | #!/usr/bin/env python3
# Copyright (c) Facebook, Inc. and its affiliates.
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
from typing import Optional
from parlai.core.params import ParlaiParser
from parlai.core.opt import Opt
from parlai.core... | 5,412 | 32.83125 | 127 | py |
null | ParlAI-main/parlai/agents/hred/README.md | # HRED Agent
The HRED agent uses a traditional LSTM encoder decoder, but also utilizes a context LSTM that encodes the history.
The following papers outline more information regarding this model:
- Building End-To-End Dialogue Systems Using Generative Hierarchical Neural Network Models [(IV Serban et al. 2015)](http... | 876 | 61.642857 | 225 | md |
null | ParlAI-main/parlai/agents/hred/__init__.py | #!/usr/bin/env python3
# Copyright (c) Facebook, Inc. and its affiliates.
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
| 199 | 32.333333 | 65 | py |
null | ParlAI-main/parlai/agents/hred/hred.py | #!/usr/bin/env python3
# Copyright (c) Facebook, Inc. and its affiliates.
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
from typing import Optional
from parlai.core.params import ParlaiParser
from parlai.core.opt import Opt
import torch
fro... | 6,521 | 35.435754 | 88 | py |
null | ParlAI-main/parlai/agents/hred/modules.py | #!/usr/bin/env python3
# Copyright (c) Facebook, Inc. and its affiliates.
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
import torch
import torch.nn as nn
from parlai.agents.seq2seq.modules import (
OutputLayer,
RNNEncoder,
_tra... | 9,697 | 30.69281 | 101 | py |
null | ParlAI-main/parlai/agents/hugging_face/README.md | # Hugging Face
We offer wrappers for generative transformers from [Hugging Face's transformers repository](https://github.com/huggingface/transformers) for fine-tuning and evaluating in ParlAI.
## GPT2
To use GPT2, run your command with the flag: `-m hugging_face/gpt2`. And suppose you want to use another model other... | 3,704 | 45.3125 | 240 | md |
null | ParlAI-main/parlai/agents/hugging_face/__init__.py | #!/usr/bin/env python3
# Copyright (c) Facebook, Inc. and its affiliates.
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
| 199 | 32.333333 | 65 | py |
null | ParlAI-main/parlai/agents/hugging_face/dialogpt.py | #!/usr/bin/env python3
# Copyright (c) Facebook, Inc. and its affiliates.
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
from typing import Optional
from parlai.core.params import ParlaiParser
from parlai.core.opt import Opt
from parlai.agen... | 4,067 | 30.534884 | 106 | py |
null | ParlAI-main/parlai/agents/hugging_face/dict.py | #!/usr/bin/env python3
# Copyright (c) Facebook, Inc. and its affiliates.
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
import os
import re
from abc import ABC, abstractmethod, abstractproperty
from collections import defaultdict
from typi... | 10,218 | 30.540123 | 87 | py |
null | ParlAI-main/parlai/agents/hugging_face/gpt2.py | #!/usr/bin/env python3
# Copyright (c) Facebook, Inc. and its affiliates.
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
from typing import Optional
from parlai.core.params import ParlaiParser
from parlai.core.opt import Opt
import os
impor... | 12,801 | 36.652941 | 122 | py |
null | ParlAI-main/parlai/agents/hugging_face/hugging_face.py | #!/usr/bin/env python3
# Copyright (c) Facebook, Inc. and its affiliates.
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
"""
Integration with Hugging Face Transformers.
Please see <https://huggingface.co/transformers/>. Currently, the only ... | 960 | 28.121212 | 86 | py |
null | ParlAI-main/parlai/agents/hugging_face/llama.py | #!/usr/bin/env python3
# Copyright (c) Facebook, Inc. and its affiliates.
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
from typing import Optional
from parlai.core.params import ParlaiParser
from parlai.core.opt import Opt
import torch
fr... | 13,241 | 34.124668 | 122 | py |
null | ParlAI-main/parlai/agents/hugging_face/t5.py | #!/usr/bin/env python3
# Copyright (c) Facebook, Inc. and its affiliates.
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
"""
T5: Exploring the Limits of Transfer Learning with a Unified Text-to-Text Transformer
See <https://arxiv.org/abs/191... | 13,721 | 32.144928 | 109 | py |
null | ParlAI-main/parlai/agents/image_seq2seq/README.md | # Image+Seq2Seq
The **Image+Seq2Seq** agent is a model that incorporates image features with a sequence to sequence transformer generator. A core component of the [dodecaDialogue](https://parl.ai/projects/dodecadialogue/) task.
## Basic Examples
Train an **Image+Seq2Seq** model on an image captioning task:
```bash
pyt... | 801 | 41.210526 | 211 | md |
null | ParlAI-main/parlai/agents/image_seq2seq/__init__.py | #!/usr/bin/env python3
# Copyright (c) Facebook, Inc. and its affiliates.
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
| 199 | 32.333333 | 65 | py |
null | ParlAI-main/parlai/agents/image_seq2seq/image_seq2seq.py | #!/usr/bin/env python3
# Copyright (c) Facebook, Inc. and its affiliates.
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
"""
Image+Seq2Seq Agent.
"""
from typing import Optional
from parlai.core.params import ParlaiParser
from parlai.core.op... | 8,317 | 36.638009 | 86 | py |
null | ParlAI-main/parlai/agents/image_seq2seq/modules.py | #!/usr/bin/env python3
# Copyright (c) Facebook, Inc. and its affiliates.
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
"""
Modules for ImageSeq2seqAgent Agent.
"""
from enum import Enum
from functools import reduce
from typing import List, ... | 15,611 | 37.078049 | 107 | py |
null | ParlAI-main/parlai/agents/ir_baseline/README.md | # IR Baseline
This agent is a simple information retrieval baseline.
If `label_candidates` are provided in the task, it simply ranks them according to their similarity to the input message. To use TF-IDF similarity, you must build a dictionary and "train" on the train set first. See the examples below for clarificatio... | 675 | 36.555556 | 252 | md |
null | ParlAI-main/parlai/agents/ir_baseline/__init__.py | #!/usr/bin/env python3
# Copyright (c) Facebook, Inc. and its affiliates.
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
| 199 | 32.333333 | 65 | py |
null | ParlAI-main/parlai/agents/ir_baseline/ir_baseline.py | #!/usr/bin/env python3
# Copyright (c) Facebook, Inc. and its affiliates.
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
"""
Simple IR baselines.
We plan to implement the following variants:
Given an input message, either:
(i) find the most ... | 9,673 | 26.022346 | 83 | py |
null | ParlAI-main/parlai/agents/local_human/README.md | # Local Human
This is an agent which takes input from the command line in the `act` function. It is used in the [interactive script](https://github.com/facebookresearch/ParlAI/blob/main/parlai/scripts/interactive.py).
## Basic Examples
Interact with a KVMemNN model trained on Persona-Chat.
```bash
python projects/pe... | 365 | 32.272727 | 203 | md |
null | ParlAI-main/parlai/agents/local_human/__init__.py | #!/usr/bin/env python3
# Copyright (c) Facebook, Inc. and its affiliates.
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
| 199 | 32.333333 | 65 | py |
null | ParlAI-main/parlai/agents/local_human/local_human.py | #!/usr/bin/env python3
# Copyright (c) Facebook, Inc. and its affiliates.
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
"""
Agent does gets the local keyboard input in the act() function.
Example: parlai eval_model -m local_human -t babi:Ta... | 3,011 | 30.375 | 85 | py |
null | ParlAI-main/parlai/agents/memnn/README.md | # MemNN
This is a memory network agent that inherits from the TorchAgent class.
Read more about Memory Networks [here](https://arxiv.org/abs/1410.3916).
## Basic Examples
Train a memory network on the bAbi task.
```bash
parlai train_model -m memnn -t babi:task10k:1 -mf /tmp/memnn_babi.mdl
```
| 298 | 22 | 72 | md |
null | ParlAI-main/parlai/agents/memnn/__init__.py | #!/usr/bin/env python3
# Copyright (c) Facebook, Inc. and its affiliates.
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
| 199 | 32.333333 | 65 | py |
null | ParlAI-main/parlai/agents/memnn/memnn.py | #!/usr/bin/env python3
# Copyright (c) Facebook, Inc. and its affiliates.
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
from typing import Optional
from parlai.core.params import ParlaiParser
from parlai.core.opt import Opt
from functools i... | 8,089 | 31.48996 | 84 | py |
null | ParlAI-main/parlai/agents/memnn/modules.py | #!/usr/bin/env python3
# Copyright (c) Facebook, Inc. and its affiliates.
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
import torch
import torch.nn as nn
from parlai.utils.torch import neginf
from functools import lru_cache
def opt_to_kw... | 7,626 | 29.630522 | 86 | py |
null | ParlAI-main/parlai/agents/rag/README.md | # Retrieval-Augmented Generation (RAG)
The code in this directory implements the [RAG Model](https://arxiv.org/abs/2005.11401) as used in the [reducing hallucination](https://parl.ai/projects/hallucination/) project. The README is broken up into the following sections:
1. Installation instructions
1. Quick-start tuto... | 13,633 | 72.301075 | 391 | md |
null | ParlAI-main/parlai/agents/rag/__init__.py | #!/usr/bin/env python3
# Copyright (c) Facebook, Inc. and its affiliates.
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
| 199 | 32.333333 | 65 | py |
null | ParlAI-main/parlai/agents/rag/args.py | #!/usr/bin/env python3
# Copyright (c) Facebook, Inc. and its affiliates.
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
"""
RAG Args.
An area to maintain RAG-Related Arguments
"""
from enum import Enum
from parlai.core.params import ParlaiP... | 12,531 | 33.428571 | 107 | py |
null | ParlAI-main/parlai/agents/rag/conversion_utils.py | #!/usr/bin/env python3
# Copyright (c) Facebook, Inc. and its affiliates.
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
"""
Conversion Scripts for RAG/DPR.
"""
from collections import OrderedDict
import os
import torch
from transformers imp... | 6,130 | 34.034286 | 97 | py |
null | ParlAI-main/parlai/agents/rag/dpr.py | #!/usr/bin/env python3
# Copyright (c) Facebook, Inc. and its affiliates.
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
"""
DPR Bi-encoder.
Wraps a DPR Model within a ParlAI Bi-encoder.
"""
from parlai.agents.transformer.transformer import T... | 10,212 | 33.271812 | 88 | py |
null | ParlAI-main/parlai/agents/rag/indexers.py | #!/usr/bin/env python3
# Copyright (c) Facebook, Inc. and its affiliates.
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
"""
FAISS-based Indexers.
Adapted from https://github.com/facebookresearch/DPR/blob/main/dpr/indexer/faiss_indexers.py
"... | 15,598 | 34.132883 | 112 | py |
null | ParlAI-main/parlai/agents/rag/model_types.py | #!/usr/bin/env python3
# Copyright (c) Facebook, Inc. and its affiliates.
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
"""
RAG Model Types.
RAG Token and RAG Sequence are outlined in https://arxiv.org/abs/2005.11401
RAG Turn is outlined i... | 48,820 | 33.356791 | 110 | py |
null | ParlAI-main/parlai/agents/rag/modules.py | #!/usr/bin/env python3
# Copyright (c) Facebook, Inc. and its affiliates.
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
"""
Modules for RAG.
"""
import torch
import torch.cuda
import torch.nn
import torch.nn.functional as F
from typing import... | 21,182 | 34.423077 | 92 | py |
null | ParlAI-main/parlai/agents/rag/polyfaiss.py | #!/usr/bin/env python3
# Copyright (c) Facebook, Inc. and its affiliates.
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
"""
PolyFAISS Query Encoder.
Contains a Wrapper for the Dropout Poly-encoder for use as a RAG Query Encoder.
"""
import t... | 3,456 | 36.576087 | 87 | py |
null | ParlAI-main/parlai/agents/rag/rag.py | #!/usr/bin/env python3
# Copyright (c) Facebook, Inc. and its affiliates.
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
"""
Retrieval-Augmented Generation for Knowledge-Intensive NLP Tasks.
Original Paper: https://arxiv.org/abs/2005.11401
... | 34,716 | 35.23904 | 109 | py |
null | ParlAI-main/parlai/agents/rag/retrieve_api.py | #!/usr/bin/env python3
# Copyright (c) Facebook, Inc. and its affiliates.
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
"""
APIs for retrieving a list of "Contents" using an "Search Query".
The term "Search Query" here refers to any abstract... | 5,245 | 33.973333 | 88 | py |
null | ParlAI-main/parlai/agents/rag/retrievers.py | #!/usr/bin/env python3
# Copyright (c) Facebook, Inc. and its affiliates.
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
"""
Retrievers for RAG.
"""
from abc import ABC, abstractmethod
import copy
import csv
import gzip
import numpy as np
impo... | 50,690 | 32.884358 | 113 | py |
null | ParlAI-main/parlai/agents/rag/scripts/__init__.py | #!/usr/bin/env python3
# Copyright (c) Facebook, Inc. and its affiliates.
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
| 198 | 38.8 | 65 | py |
null | ParlAI-main/parlai/agents/rag/scripts/generate_dense_embeddings.py | #!/usr/bin/env python3
# Copyright (c) Facebook, Inc. and its affiliates.
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
"""
Generate Dense Embeddings for use in a FAISS Index.
Modified/Adapted from https://github.com/facebookresearch/DPR/bl... | 7,678 | 34.550926 | 104 | py |
null | ParlAI-main/parlai/agents/rag/scripts/index_dense_embeddings.py | #!/usr/bin/env python3
# Copyright (c) Facebook, Inc. and its affiliates.
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
"""
Create a FAISS Index with a series of dense embeddings.
"""
import os
import random
import torch
from typing import L... | 4,832 | 29.980769 | 110 | py |
null | ParlAI-main/parlai/agents/random_candidate/README.md | # Random Candidate
This is an agent which chooses a random label candidate, to be used for debugging or as an extremely simple baseline.
If label candidates are available for the task, it chooses one randomly as a response. It randomly sorts the candidates to return in the `text_candidates` field, used for calculatin... | 531 | 39.923077 | 264 | md |
null | ParlAI-main/parlai/agents/random_candidate/__init__.py | #!/usr/bin/env python3
# Copyright (c) Facebook, Inc. and its affiliates.
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
| 199 | 32.333333 | 65 | py |
null | ParlAI-main/parlai/agents/random_candidate/random_candidate.py | #!/usr/bin/env python3
# Copyright (c) Facebook, Inc. and its affiliates.
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
"""
Simple agent which chooses a random label.
Chooses from the label candidates if they are available. If candidates ar... | 2,698 | 31.130952 | 78 | py |
null | ParlAI-main/parlai/agents/repeat_label/README.md | # Repeat Label
This is an agent which simply repeats the label for debugging purposes or as a baseline.
## Basic Examples
Evaluate on bAbi, returning the answer "I don't know" roughly 20% of the time.
```bash
parlai eval_model -m repeat_label -t babi --cant_answer_percent 0.2
```
| 284 | 24.909091 | 88 | md |
null | ParlAI-main/parlai/agents/repeat_label/__init__.py | #!/usr/bin/env python3
# Copyright (c) Facebook, Inc. and its affiliates.
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
| 199 | 32.333333 | 65 | py |
null | ParlAI-main/parlai/agents/repeat_label/repeat_label.py | #!/usr/bin/env python3
# Copyright (c) Facebook, Inc. and its affiliates.
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
"""
Simple agent which repeats back the labels sent to it.
By default, replies with a single random label from the list ... | 3,041 | 33.965517 | 87 | py |
null | ParlAI-main/parlai/agents/repeat_query/README.md | # Repeat Query
This is an agent which simply repeats the query for debugging purposes or as a baseline.
## Basic Examples
Evaluate on bAbi, displaying the answers.
```bash
parlai display_model -m repeat_query -t babi
```
| 224 | 19.454545 | 88 | md |
null | ParlAI-main/parlai/agents/repeat_query/__init__.py | #!/usr/bin/env python3
# Copyright (c) Facebook, Inc. and its affiliates.
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
| 199 | 32.333333 | 65 | py |
null | ParlAI-main/parlai/agents/repeat_query/repeat_query.py | #!/usr/bin/env python3
# Copyright (c) Facebook, Inc. and its affiliates.
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
"""
Simple agent which repeats back the last thing said to it.
Useful as a baseline for metrics like F1.
"""
from parla... | 1,328 | 29.906977 | 85 | py |
null | ParlAI-main/parlai/agents/reranker/README.md | # Output Reranker
This agent provides an abstract implementation of a "re-ranker" object, as well as an abstract implementation of a `TransformerGeneratorAgent` that utilizes the re-ranker. A re-ranker can be used to re-rank outputs according to some other model's predictor score. The below steps outline how to build ... | 3,364 | 60.181818 | 357 | md |
null | ParlAI-main/parlai/agents/reranker/__init__.py | #!/usr/bin/env python3
# Copyright (c) Facebook, Inc. and its affiliates.
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
| 199 | 32.333333 | 65 | py |
null | ParlAI-main/parlai/agents/reranker/classifier_gpt2_reranker.py | #!/usr/bin/env python3
# Copyright (c) Facebook, Inc. and its affiliates.
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
"""
Classifier Gpt2 Re-Ranker Object.
Provided with a classifier model file, the gpt2 re-ranker provides an API for re-r... | 849 | 29.357143 | 88 | py |
null | ParlAI-main/parlai/agents/reranker/classifier_reranker.py | #!/usr/bin/env python3
# Copyright (c) Facebook, Inc. and its affiliates.
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
"""
Classifier Re-Ranker Object.
Provided with a classifier model file, the re-ranker provides an API for re-ranking
can... | 3,899 | 33.210526 | 101 | py |
null | ParlAI-main/parlai/agents/reranker/reranker.py | #!/usr/bin/env python3
# Copyright (c) Facebook, Inc. and its affiliates.
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
"""
Re-Ranker Object.
Provided with a predictor model file, the re-ranker provides an API for re-ranking
candidate outpu... | 22,618 | 35.482258 | 230 | py |
null | ParlAI-main/parlai/agents/retriever_reader/README.md | # Retriever Reader
This Retriever Reader is an agent which first retrieves from a database and then reads the dialogue + knowledge
from the database to answer.
NOTE: this model only works for evaluation; it assumes all training is already done.
## Basic Examples
Evaluate a pre-trained model on Open SQuAD. This model ... | 438 | 35.583333 | 121 | md |
null | ParlAI-main/parlai/agents/retriever_reader/__init__.py | #!/usr/bin/env python3
# Copyright (c) Facebook, Inc. and its affiliates.
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
| 199 | 32.333333 | 65 | py |
null | ParlAI-main/parlai/agents/retriever_reader/retriever_reader.py | #!/usr/bin/env python3
# Copyright (c) Facebook, Inc. and its affiliates.
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
"""
Agent which first retrieves from a database and then reads the dialogue + knowledge from
the database to answer.
NOT... | 3,905 | 33.263158 | 88 | py |
null | ParlAI-main/parlai/agents/safe_local_human/README.md | # Safe Local Human
This is an agent which takes input from the command line in the `act` function, and applies a safety classifier to process the messages. It is used in the [safe interactive script](https://github.com/facebookresearch/ParlAI/blob/main/parlai/scripts/safe_interactive.py).
## Basic Examples
Interact ... | 461 | 41 | 270 | md |
null | ParlAI-main/parlai/agents/safe_local_human/__init__.py | #!/usr/bin/env python3
# Copyright (c) Facebook, Inc. and its affiliates.
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
| 199 | 32.333333 | 65 | py |
null | ParlAI-main/parlai/agents/safe_local_human/safe_local_human.py | #!/usr/bin/env python3
# Copyright (c) Facebook, Inc. and its affiliates.
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
"""
Agent that gets the local keyboard input in the act() function.
Applies safety classifier(s) to process user and par... | 4,597 | 31.380282 | 87 | py |
null | ParlAI-main/parlai/agents/seq2seq/README.md | # Seq2Seq Agent
The Seq2Seq agent takes an input sequence and produces an output sequence.
The agent supports encoding and decoding via a variety of RNN flavors,
including LSTMs and GRUs. The agent supports encoding and decoding via a
variety of RNN flavors, including LSTMs and GRUs. It also supports numerous
decodin... | 827 | 47.705882 | 75 | md |
null | ParlAI-main/parlai/agents/seq2seq/__init__.py | #!/usr/bin/env python3
# Copyright (c) Facebook, Inc. and its affiliates.
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
| 199 | 32.333333 | 65 | py |
null | ParlAI-main/parlai/agents/seq2seq/modules.py | #!/usr/bin/env python3
# Copyright (c) Facebook, Inc. and its affiliates.
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
"""
Module files as torch.nn.Module subclasses for Seq2seqAgent.
"""
import math
import torch
import torch.nn as nn
fro... | 24,820 | 34.157224 | 98 | py |
null | ParlAI-main/parlai/agents/seq2seq/seq2seq.py | #!/usr/bin/env python3
# Copyright (c) Facebook, Inc. and its affiliates.
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
from typing import Optional
from parlai.core.params import ParlaiParser
from parlai.core.opt import Opt
from parlai.core... | 9,302 | 34.643678 | 88 | py |
null | ParlAI-main/parlai/agents/starspace/README.md | # Starspace
This agent contains a simple implementation of the *starspace* algorithm, slightly adapted for dialogue. To learn more about the starspace algorithm, see [this](https://arxiv.org/abs/1709.03856) paper.
## Basic Examples
Train a starspace model on the "sentence SQuAD" [task](https://github.com/facebookre... | 494 | 40.25 | 201 | md |
null | ParlAI-main/parlai/agents/starspace/__init__.py | #!/usr/bin/env python3
# Copyright (c) Facebook, Inc. and its affiliates.
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
| 199 | 32.333333 | 65 | py |
null | ParlAI-main/parlai/agents/starspace/modules.py | #!/usr/bin/env python3
# Copyright (c) Facebook, Inc. and its affiliates.
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
import math
import torch
import torch.nn as nn
class Starspace(nn.Module):
def __init__(self, opt, num_features, d... | 2,571 | 28.906977 | 84 | py |
null | ParlAI-main/parlai/agents/starspace/starspace.py | #!/usr/bin/env python3
# Copyright (c) Facebook, Inc. and its affiliates.
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
#
# Simple implementation of the starspace algorithm, slightly adapted for dialogue.
# See: https://arxiv.org/abs/1709.03... | 20,522 | 34.445596 | 89 | py |
null | ParlAI-main/parlai/agents/test_agents/README.md | # Test Agents
Agents used in unit testing.
| 44 | 10.25 | 28 | md |
null | ParlAI-main/parlai/agents/test_agents/__init__.py | 0 | 0 | 0 | py | |
null | ParlAI-main/parlai/agents/test_agents/counter.py | #!/usr/bin/env python3
# Copyright (c) Facebook, Inc. and its affiliates.
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
"""
Test agent which counts its number of unique items.
"""
from __future__ import annotations
from typing import Tuple... | 3,451 | 24.57037 | 86 | py |
null | ParlAI-main/parlai/agents/test_agents/null.py | #!/usr/bin/env python3
# Copyright (c) Facebook, Inc. and its affiliates.
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
import torch
from parlai.core.torch_agent import TorchAgent, Output
class NullAgent(TorchAgent):
"""
A agent w... | 807 | 22.764706 | 65 | py |