├── .gitignore ├── Basic Rag ├── requirements.txt └── test.ipynb ├── LICENSE ├── Llama2_with_llamaindex.ipynb └── README.md /.gitignore: -------------------------------------------------------------------------------- 1 | # Byte-compiled / optimized / DLL files 2 | __pycache__/ 3 | *.py[cod] 4 | *$py.class 5 | 6 | # C extensions 7 | *.so 8 | 9 | # Distribution / packaging 10 | .Python 11 | build/ 12 | develop-eggs/ 13 | dist/ 14 | downloads/ 15 | eggs/ 16 | .eggs/ 17 | lib/ 18 | lib64/ 19 | parts/ 20 | sdist/ 21 | var/ 22 | wheels/ 23 | share/python-wheels/ 24 | *.egg-info/ 25 | .installed.cfg 26 | *.egg 27 | MANIFEST 28 | 29 | # PyInstaller 30 | # Usually these files are written by a python script from a template 31 | # before PyInstaller builds the exe, so as to inject date/other infos into it. 32 | *.manifest 33 | *.spec 34 | 35 | # Installer logs 36 | pip-log.txt 37 | pip-delete-this-directory.txt 38 | 39 | # Unit test / coverage reports 40 | htmlcov/ 41 | .tox/ 42 | .nox/ 43 | .coverage 44 | .coverage.* 45 | .cache 46 | nosetests.xml 47 | coverage.xml 48 | *.cover 49 | *.py,cover 50 | .hypothesis/ 51 | .pytest_cache/ 52 | cover/ 53 | 54 | # Translations 55 | *.mo 56 | *.pot 57 | 58 | # Django stuff: 59 | *.log 60 | local_settings.py 61 | db.sqlite3 62 | db.sqlite3-journal 63 | 64 | # Flask stuff: 65 | instance/ 66 | .webassets-cache 67 | 68 | # Scrapy stuff: 69 | .scrapy 70 | 71 | # Sphinx documentation 72 | docs/_build/ 73 | 74 | # PyBuilder 75 | .pybuilder/ 76 | target/ 77 | 78 | # Jupyter Notebook 79 | .ipynb_checkpoints 80 | 81 | # IPython 82 | profile_default/ 83 | ipython_config.py 84 | 85 | # pyenv 86 | # For a library or package, you might want to ignore these files since the code is 87 | # intended to run in multiple environments; otherwise, check them in: 88 | # .python-version 89 | 90 | # pipenv 91 | # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. 92 | # However, in case of collaboration, if having platform-specific dependencies or dependencies 93 | # having no cross-platform support, pipenv may install dependencies that don't work, or not 94 | # install all needed dependencies. 95 | #Pipfile.lock 96 | 97 | # poetry 98 | # Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control. 99 | # This is especially recommended for binary packages to ensure reproducibility, and is more 100 | # commonly ignored for libraries. 101 | # https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control 102 | #poetry.lock 103 | 104 | # pdm 105 | # Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control. 106 | #pdm.lock 107 | # pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it 108 | # in version control. 109 | # https://pdm.fming.dev/#use-with-ide 110 | .pdm.toml 111 | 112 | # PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm 113 | __pypackages__/ 114 | 115 | # Celery stuff 116 | celerybeat-schedule 117 | celerybeat.pid 118 | 119 | # SageMath parsed files 120 | *.sage.py 121 | 122 | # Environments 123 | .env 124 | .venv 125 | env/ 126 | venv/ 127 | ENV/ 128 | env.bak/ 129 | venv.bak/ 130 | 131 | # Spyder project settings 132 | .spyderproject 133 | .spyproject 134 | 135 | # Rope project settings 136 | .ropeproject 137 | 138 | # mkdocs documentation 139 | /site 140 | 141 | # mypy 142 | .mypy_cache/ 143 | .dmypy.json 144 | dmypy.json 145 | 146 | # Pyre type checker 147 | .pyre/ 148 | 149 | # pytype static type analyzer 150 | .pytype/ 151 | 152 | # Cython debug symbols 153 | cython_debug/ 154 | 155 | # PyCharm 156 | # JetBrains specific template is maintained in a separate JetBrains.gitignore that can 157 | # be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore 158 | # and can be added to the global gitignore or merged into this file. For a more nuclear 159 | # option (not recommended) you can uncomment the following to ignore the entire idea folder. 160 | #.idea/ 161 | -------------------------------------------------------------------------------- /Basic Rag/requirements.txt: -------------------------------------------------------------------------------- 1 | llama-index 2 | openai 3 | pypdf 4 | python-dotenv -------------------------------------------------------------------------------- /Basic Rag/test.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "code", 5 | "execution_count": 1, 6 | "metadata": {}, 7 | "outputs": [ 8 | { 9 | "data": { 10 | "text/plain": [ 11 | "True" 12 | ] 13 | }, 14 | "execution_count": 1, 15 | "metadata": {}, 16 | "output_type": "execute_result" 17 | } 18 | ], 19 | "source": [ 20 | "## Retrieval augmented generation\n", 21 | "\n", 22 | "import os\n", 23 | "from dotenv import load_dotenv\n", 24 | "load_dotenv()\n" 25 | ] 26 | }, 27 | { 28 | "cell_type": "code", 29 | "execution_count": 2, 30 | "metadata": {}, 31 | "outputs": [], 32 | "source": [ 33 | "os.environ['OPENAI_API_KEY']=os.getenv(\"OPENAI_API_KEY\")" 34 | ] 35 | }, 36 | { 37 | "cell_type": "code", 38 | "execution_count": 3, 39 | "metadata": {}, 40 | "outputs": [], 41 | "source": [ 42 | "from llama_index import VectorStoreIndex,SimpleDirectoryReader\n", 43 | "documents=SimpleDirectoryReader(\"data\").load_data()" 44 | ] 45 | }, 46 | { 47 | "cell_type": "code", 48 | "execution_count": 4, 49 | "metadata": {}, 50 | "outputs": [ 51 | { 52 | "data": { 53 | "text/plain": [ 54 | "[Document(id_='dd2ceadf-1a28-4ae3-b024-9db1bd4c45ff', embedding=None, metadata={'page_label': '1', 'file_name': 'attention.pdf', 'file_path': 'data\\\\attention.pdf', 'file_type': 'application/pdf', 'file_size': 2215244, 'creation_date': '2024-01-29', 'last_modified_date': '2024-01-29', 'last_accessed_date': '2024-01-29'}, excluded_embed_metadata_keys=['file_name', 'file_type', 'file_size', 'creation_date', 'last_modified_date', 'last_accessed_date'], excluded_llm_metadata_keys=['file_name', 'file_type', 'file_size', 'creation_date', 'last_modified_date', 'last_accessed_date'], relationships={}, text='Provided proper attribution is provided, Google hereby grants permission to\\nreproduce the tables and figures in this paper solely for use in journalistic or\\nscholarly works.\\nAttention Is All You Need\\nAshish Vaswani∗\\nGoogle Brain\\navaswani@google.comNoam Shazeer∗\\nGoogle Brain\\nnoam@google.comNiki Parmar∗\\nGoogle Research\\nnikip@google.comJakob Uszkoreit∗\\nGoogle Research\\nusz@google.com\\nLlion Jones∗\\nGoogle Research\\nllion@google.comAidan N. Gomez∗ †\\nUniversity of Toronto\\naidan@cs.toronto.eduŁukasz Kaiser∗\\nGoogle Brain\\nlukaszkaiser@google.com\\nIllia Polosukhin∗ ‡\\nillia.polosukhin@gmail.com\\nAbstract\\nThe dominant sequence transduction models are based on complex recurrent or\\nconvolutional neural networks that include an encoder and a decoder. The best\\nperforming models also connect the encoder and decoder through an attention\\nmechanism. We propose a new simple network architecture, the Transformer,\\nbased solely on attention mechanisms, dispensing with recurrence and convolutions\\nentirely. Experiments on two machine translation tasks show these models to\\nbe superior in quality while being more parallelizable and requiring significantly\\nless time to train. Our model achieves 28.4 BLEU on the WMT 2014 English-\\nto-German translation task, improving over the existing best results, including\\nensembles, by over 2 BLEU. On the WMT 2014 English-to-French translation task,\\nour model establishes a new single-model state-of-the-art BLEU score of 41.8 after\\ntraining for 3.5 days on eight GPUs, a small fraction of the training costs of the\\nbest models from the literature. We show that the Transformer generalizes well to\\nother tasks by applying it successfully to English constituency parsing both with\\nlarge and limited training data.\\n∗Equal contribution. Listing order is random. Jakob proposed replacing RNNs with self-attention and started\\nthe effort to evaluate this idea. Ashish, with Illia, designed and implemented the first Transformer models and\\nhas been crucially involved in every aspect of this work. Noam proposed scaled dot-product attention, multi-head\\nattention and the parameter-free position representation and became the other person involved in nearly every\\ndetail. Niki designed, implemented, tuned and evaluated countless model variants in our original codebase and\\ntensor2tensor. Llion also experimented with novel model variants, was responsible for our initial codebase, and\\nefficient inference and visualizations. Lukasz and Aidan spent countless long days designing various parts of and\\nimplementing tensor2tensor, replacing our earlier codebase, greatly improving results and massively accelerating\\nour research.\\n†Work performed while at Google Brain.\\n‡Work performed while at Google Research.\\n31st Conference on Neural Information Processing Systems (NIPS 2017), Long Beach, CA, USA.arXiv:1706.03762v7 [cs.CL] 2 Aug 2023', start_char_idx=None, end_char_idx=None, text_template='{metadata_str}\\n\\n{content}', metadata_template='{key}: {value}', metadata_seperator='\\n'),\n", 55 | " Document(id_='96e4e319-caae-4f1e-8bd6-0a50366e4458', embedding=None, metadata={'page_label': '2', 'file_name': 'attention.pdf', 'file_path': 'data\\\\attention.pdf', 'file_type': 'application/pdf', 'file_size': 2215244, 'creation_date': '2024-01-29', 'last_modified_date': '2024-01-29', 'last_accessed_date': '2024-01-29'}, excluded_embed_metadata_keys=['file_name', 'file_type', 'file_size', 'creation_date', 'last_modified_date', 'last_accessed_date'], excluded_llm_metadata_keys=['file_name', 'file_type', 'file_size', 'creation_date', 'last_modified_date', 'last_accessed_date'], relationships={}, text='1 Introduction\\nRecurrent neural networks, long short-term memory [ 13] and gated recurrent [ 7] neural networks\\nin particular, have been firmly established as state of the art approaches in sequence modeling and\\ntransduction problems such as language modeling and machine translation [ 35,2,5]. Numerous\\nefforts have since continued to push the boundaries of recurrent language models and encoder-decoder\\narchitectures [38, 24, 15].\\nRecurrent models typically factor computation along the symbol positions of the input and output\\nsequences. Aligning the positions to steps in computation time, they generate a sequence of hidden\\nstates ht, as a function of the previous hidden state ht−1and the input for position t. This inherently\\nsequential nature precludes parallelization within training examples, which becomes critical at longer\\nsequence lengths, as memory constraints limit batching across examples. Recent work has achieved\\nsignificant improvements in computational efficiency through factorization tricks [ 21] and conditional\\ncomputation [ 32], while also improving model performance in case of the latter. The fundamental\\nconstraint of sequential computation, however, remains.\\nAttention mechanisms have become an integral part of compelling sequence modeling and transduc-\\ntion models in various tasks, allowing modeling of dependencies without regard to their distance in\\nthe input or output sequences [ 2,19]. In all but a few cases [ 27], however, such attention mechanisms\\nare used in conjunction with a recurrent network.\\nIn this work we propose the Transformer, a model architecture eschewing recurrence and instead\\nrelying entirely on an attention mechanism to draw global dependencies between input and output.\\nThe Transformer allows for significantly more parallelization and can reach a new state of the art in\\ntranslation quality after being trained for as little as twelve hours on eight P100 GPUs.\\n2 Background\\nThe goal of reducing sequential computation also forms the foundation of the Extended Neural GPU\\n[16], ByteNet [ 18] and ConvS2S [ 9], all of which use convolutional neural networks as basic building\\nblock, computing hidden representations in parallel for all input and output positions. In these models,\\nthe number of operations required to relate signals from two arbitrary input or output positions grows\\nin the distance between positions, linearly for ConvS2S and logarithmically for ByteNet. This makes\\nit more difficult to learn dependencies between distant positions [ 12]. In the Transformer this is\\nreduced to a constant number of operations, albeit at the cost of reduced effective resolution due\\nto averaging attention-weighted positions, an effect we counteract with Multi-Head Attention as\\ndescribed in section 3.2.\\nSelf-attention, sometimes called intra-attention is an attention mechanism relating different positions\\nof a single sequence in order to compute a representation of the sequence. Self-attention has been\\nused successfully in a variety of tasks including reading comprehension, abstractive summarization,\\ntextual entailment and learning task-independent sentence representations [4, 27, 28, 22].\\nEnd-to-end memory networks are based on a recurrent attention mechanism instead of sequence-\\naligned recurrence and have been shown to perform well on simple-language question answering and\\nlanguage modeling tasks [34].\\nTo the best of our knowledge, however, the Transformer is the first transduction model relying\\nentirely on self-attention to compute representations of its input and output without using sequence-\\naligned RNNs or convolution. In the following sections, we will describe the Transformer, motivate\\nself-attention and discuss its advantages over models such as [17, 18] and [9].\\n3 Model Architecture\\nMost competitive neural sequence transduction models have an encoder-decoder structure [ 5,2,35].\\nHere, the encoder maps an input sequence of symbol representations (x1, ..., x n)to a sequence\\nof continuous representations z= (z1, ..., z n). Given z, the decoder then generates an output\\nsequence (y1, ..., y m)of symbols one element at a time. At each step the model is auto-regressive\\n[10], consuming the previously generated symbols as additional input when generating the next.\\n2', start_char_idx=None, end_char_idx=None, text_template='{metadata_str}\\n\\n{content}', metadata_template='{key}: {value}', metadata_seperator='\\n'),\n", 56 | " Document(id_='e981fec9-cde5-481d-963c-30e0c61561e7', embedding=None, metadata={'page_label': '3', 'file_name': 'attention.pdf', 'file_path': 'data\\\\attention.pdf', 'file_type': 'application/pdf', 'file_size': 2215244, 'creation_date': '2024-01-29', 'last_modified_date': '2024-01-29', 'last_accessed_date': '2024-01-29'}, excluded_embed_metadata_keys=['file_name', 'file_type', 'file_size', 'creation_date', 'last_modified_date', 'last_accessed_date'], excluded_llm_metadata_keys=['file_name', 'file_type', 'file_size', 'creation_date', 'last_modified_date', 'last_accessed_date'], relationships={}, text='Figure 1: The Transformer - model architecture.\\nThe Transformer follows this overall architecture using stacked self-attention and point-wise, fully\\nconnected layers for both the encoder and decoder, shown in the left and right halves of Figure 1,\\nrespectively.\\n3.1 Encoder and Decoder Stacks\\nEncoder: The encoder is composed of a stack of N= 6 identical layers. Each layer has two\\nsub-layers. The first is a multi-head self-attention mechanism, and the second is a simple, position-\\nwise fully connected feed-forward network. We employ a residual connection [ 11] around each of\\nthe two sub-layers, followed by layer normalization [ 1]. That is, the output of each sub-layer is\\nLayerNorm( x+ Sublayer( x)), where Sublayer( x)is the function implemented by the sub-layer\\nitself. To facilitate these residual connections, all sub-layers in the model, as well as the embedding\\nlayers, produce outputs of dimension dmodel = 512 .\\nDecoder: The decoder is also composed of a stack of N= 6identical layers. In addition to the two\\nsub-layers in each encoder layer, the decoder inserts a third sub-layer, which performs multi-head\\nattention over the output of the encoder stack. Similar to the encoder, we employ residual connections\\naround each of the sub-layers, followed by layer normalization. We also modify the self-attention\\nsub-layer in the decoder stack to prevent positions from attending to subsequent positions. This\\nmasking, combined with fact that the output embeddings are offset by one position, ensures that the\\npredictions for position ican depend only on the known outputs at positions less than i.\\n3.2 Attention\\nAn attention function can be described as mapping a query and a set of key-value pairs to an output,\\nwhere the query, keys, values, and output are all vectors. The output is computed as a weighted sum\\n3', start_char_idx=None, end_char_idx=None, text_template='{metadata_str}\\n\\n{content}', metadata_template='{key}: {value}', metadata_seperator='\\n'),\n", 57 | " Document(id_='7dea8f3e-f27d-4983-a27e-288b8e76f078', embedding=None, metadata={'page_label': '4', 'file_name': 'attention.pdf', 'file_path': 'data\\\\attention.pdf', 'file_type': 'application/pdf', 'file_size': 2215244, 'creation_date': '2024-01-29', 'last_modified_date': '2024-01-29', 'last_accessed_date': '2024-01-29'}, excluded_embed_metadata_keys=['file_name', 'file_type', 'file_size', 'creation_date', 'last_modified_date', 'last_accessed_date'], excluded_llm_metadata_keys=['file_name', 'file_type', 'file_size', 'creation_date', 'last_modified_date', 'last_accessed_date'], relationships={}, text='Scaled Dot-Product Attention\\n Multi-Head Attention\\nFigure 2: (left) Scaled Dot-Product Attention. (right) Multi-Head Attention consists of several\\nattention layers running in parallel.\\nof the values, where the weight assigned to each value is computed by a compatibility function of the\\nquery with the corresponding key.\\n3.2.1 Scaled Dot-Product Attention\\nWe call our particular attention \"Scaled Dot-Product Attention\" (Figure 2). The input consists of\\nqueries and keys of dimension dk, and values of dimension dv. We compute the dot products of the\\nquery with all keys, divide each by√dk, and apply a softmax function to obtain the weights on the\\nvalues.\\nIn practice, we compute the attention function on a set of queries simultaneously, packed together\\ninto a matrix Q. The keys and values are also packed together into matrices KandV. We compute\\nthe matrix of outputs as:\\nAttention( Q, K, V ) = softmax(QKT\\n√dk)V (1)\\nThe two most commonly used attention functions are additive attention [ 2], and dot-product (multi-\\nplicative) attention. Dot-product attention is identical to our algorithm, except for the scaling factor\\nof1√dk. Additive attention computes the compatibility function using a feed-forward network with\\na single hidden layer. While the two are similar in theoretical complexity, dot-product attention is\\nmuch faster and more space-efficient in practice, since it can be implemented using highly optimized\\nmatrix multiplication code.\\nWhile for small values of dkthe two mechanisms perform similarly, additive attention outperforms\\ndot product attention without scaling for larger values of dk[3]. We suspect that for large values of\\ndk, the dot products grow large in magnitude, pushing the softmax function into regions where it has\\nextremely small gradients4. To counteract this effect, we scale the dot products by1√dk.\\n3.2.2 Multi-Head Attention\\nInstead of performing a single attention function with dmodel-dimensional keys, values and queries,\\nwe found it beneficial to linearly project the queries, keys and values htimes with different, learned\\nlinear projections to dk,dkanddvdimensions, respectively. On each of these projected versions of\\nqueries, keys and values we then perform the attention function in parallel, yielding dv-dimensional\\n4To illustrate why the dot products get large, assume that the components of qandkare independent random\\nvariables with mean 0and variance 1. Then their dot product, q·k=Pdk\\ni=1qiki, has mean 0and variance dk.\\n4', start_char_idx=None, end_char_idx=None, text_template='{metadata_str}\\n\\n{content}', metadata_template='{key}: {value}', metadata_seperator='\\n'),\n", 58 | " Document(id_='6aaa9302-e06e-4703-aaee-ae76ac833da9', embedding=None, metadata={'page_label': '5', 'file_name': 'attention.pdf', 'file_path': 'data\\\\attention.pdf', 'file_type': 'application/pdf', 'file_size': 2215244, 'creation_date': '2024-01-29', 'last_modified_date': '2024-01-29', 'last_accessed_date': '2024-01-29'}, excluded_embed_metadata_keys=['file_name', 'file_type', 'file_size', 'creation_date', 'last_modified_date', 'last_accessed_date'], excluded_llm_metadata_keys=['file_name', 'file_type', 'file_size', 'creation_date', 'last_modified_date', 'last_accessed_date'], relationships={}, text='output values. These are concatenated and once again projected, resulting in the final values, as\\ndepicted in Figure 2.\\nMulti-head attention allows the model to jointly attend to information from different representation\\nsubspaces at different positions. With a single attention head, averaging inhibits this.\\nMultiHead( Q, K, V ) = Concat(head 1, ...,head h)WO\\nwhere head i= Attention( QWQ\\ni, KWK\\ni, V WV\\ni)\\nWhere the projections are parameter matrices WQ\\ni∈Rdmodel×dk,WK\\ni∈Rdmodel×dk,WV\\ni∈Rdmodel×dv\\nandWO∈Rhdv×dmodel.\\nIn this work we employ h= 8 parallel attention layers, or heads. For each of these we use\\ndk=dv=dmodel/h= 64 . Due to the reduced dimension of each head, the total computational cost\\nis similar to that of single-head attention with full dimensionality.\\n3.2.3 Applications of Attention in our Model\\nThe Transformer uses multi-head attention in three different ways:\\n•In \"encoder-decoder attention\" layers, the queries come from the previous decoder layer,\\nand the memory keys and values come from the output of the encoder. This allows every\\nposition in the decoder to attend over all positions in the input sequence. This mimics the\\ntypical encoder-decoder attention mechanisms in sequence-to-sequence models such as\\n[38, 2, 9].\\n•The encoder contains self-attention layers. In a self-attention layer all of the keys, values\\nand queries come from the same place, in this case, the output of the previous layer in the\\nencoder. Each position in the encoder can attend to all positions in the previous layer of the\\nencoder.\\n•Similarly, self-attention layers in the decoder allow each position in the decoder to attend to\\nall positions in the decoder up to and including that position. We need to prevent leftward\\ninformation flow in the decoder to preserve the auto-regressive property. We implement this\\ninside of scaled dot-product attention by masking out (setting to −∞) all values in the input\\nof the softmax which correspond to illegal connections. See Figure 2.\\n3.3 Position-wise Feed-Forward Networks\\nIn addition to attention sub-layers, each of the layers in our encoder and decoder contains a fully\\nconnected feed-forward network, which is applied to each position separately and identically. This\\nconsists of two linear transformations with a ReLU activation in between.\\nFFN( x) = max(0 , xW 1+b1)W2+b2 (2)\\nWhile the linear transformations are the same across different positions, they use different parameters\\nfrom layer to layer. Another way of describing this is as two convolutions with kernel size 1.\\nThe dimensionality of input and output is dmodel = 512 , and the inner-layer has dimensionality\\ndff= 2048 .\\n3.4 Embeddings and Softmax\\nSimilarly to other sequence transduction models, we use learned embeddings to convert the input\\ntokens and output tokens to vectors of dimension dmodel. We also use the usual learned linear transfor-\\nmation and softmax function to convert the decoder output to predicted next-token probabilities. In\\nour model, we share the same weight matrix between the two embedding layers and the pre-softmax\\nlinear transformation, similar to [ 30]. In the embedding layers, we multiply those weights by√dmodel.\\n5', start_char_idx=None, end_char_idx=None, text_template='{metadata_str}\\n\\n{content}', metadata_template='{key}: {value}', metadata_seperator='\\n'),\n", 59 | " Document(id_='5ae96bee-cdb7-40ab-abe6-45aaeb2906cf', embedding=None, metadata={'page_label': '6', 'file_name': 'attention.pdf', 'file_path': 'data\\\\attention.pdf', 'file_type': 'application/pdf', 'file_size': 2215244, 'creation_date': '2024-01-29', 'last_modified_date': '2024-01-29', 'last_accessed_date': '2024-01-29'}, excluded_embed_metadata_keys=['file_name', 'file_type', 'file_size', 'creation_date', 'last_modified_date', 'last_accessed_date'], excluded_llm_metadata_keys=['file_name', 'file_type', 'file_size', 'creation_date', 'last_modified_date', 'last_accessed_date'], relationships={}, text='Table 1: Maximum path lengths, per-layer complexity and minimum number of sequential operations\\nfor different layer types. nis the sequence length, dis the representation dimension, kis the kernel\\nsize of convolutions and rthe size of the neighborhood in restricted self-attention.\\nLayer Type Complexity per Layer Sequential Maximum Path Length\\nOperations\\nSelf-Attention O(n2·d) O(1) O(1)\\nRecurrent O(n·d2) O(n) O(n)\\nConvolutional O(k·n·d2) O(1) O(logk(n))\\nSelf-Attention (restricted) O(r·n·d) O(1) O(n/r)\\n3.5 Positional Encoding\\nSince our model contains no recurrence and no convolution, in order for the model to make use of the\\norder of the sequence, we must inject some information about the relative or absolute position of the\\ntokens in the sequence. To this end, we add \"positional encodings\" to the input embeddings at the\\nbottoms of the encoder and decoder stacks. The positional encodings have the same dimension dmodel\\nas the embeddings, so that the two can be summed. There are many choices of positional encodings,\\nlearned and fixed [9].\\nIn this work, we use sine and cosine functions of different frequencies:\\nPE(pos,2i)=sin(pos/100002i/d model)\\nPE(pos,2i+1)=cos(pos/100002i/d model)\\nwhere posis the position and iis the dimension. That is, each dimension of the positional encoding\\ncorresponds to a sinusoid. The wavelengths form a geometric progression from 2πto10000 ·2π. We\\nchose this function because we hypothesized it would allow the model to easily learn to attend by\\nrelative positions, since for any fixed offset k,PEpos+kcan be represented as a linear function of\\nPEpos.\\nWe also experimented with using learned positional embeddings [ 9] instead, and found that the two\\nversions produced nearly identical results (see Table 3 row (E)). We chose the sinusoidal version\\nbecause it may allow the model to extrapolate to sequence lengths longer than the ones encountered\\nduring training.\\n4 Why Self-Attention\\nIn this section we compare various aspects of self-attention layers to the recurrent and convolu-\\ntional layers commonly used for mapping one variable-length sequence of symbol representations\\n(x1, ..., x n)to another sequence of equal length (z1, ..., z n), with xi, zi∈Rd, such as a hidden\\nlayer in a typical sequence transduction encoder or decoder. Motivating our use of self-attention we\\nconsider three desiderata.\\nOne is the total computational complexity per layer. Another is the amount of computation that can\\nbe parallelized, as measured by the minimum number of sequential operations required.\\nThe third is the path length between long-range dependencies in the network. Learning long-range\\ndependencies is a key challenge in many sequence transduction tasks. One key factor affecting the\\nability to learn such dependencies is the length of the paths forward and backward signals have to\\ntraverse in the network. The shorter these paths between any combination of positions in the input\\nand output sequences, the easier it is to learn long-range dependencies [ 12]. Hence we also compare\\nthe maximum path length between any two input and output positions in networks composed of the\\ndifferent layer types.\\nAs noted in Table 1, a self-attention layer connects all positions with a constant number of sequentially\\nexecuted operations, whereas a recurrent layer requires O(n)sequential operations. In terms of\\ncomputational complexity, self-attention layers are faster than recurrent layers when the sequence\\n6', start_char_idx=None, end_char_idx=None, text_template='{metadata_str}\\n\\n{content}', metadata_template='{key}: {value}', metadata_seperator='\\n'),\n", 60 | " Document(id_='14ec34f3-a9a1-4f09-b609-d084824a4445', embedding=None, metadata={'page_label': '7', 'file_name': 'attention.pdf', 'file_path': 'data\\\\attention.pdf', 'file_type': 'application/pdf', 'file_size': 2215244, 'creation_date': '2024-01-29', 'last_modified_date': '2024-01-29', 'last_accessed_date': '2024-01-29'}, excluded_embed_metadata_keys=['file_name', 'file_type', 'file_size', 'creation_date', 'last_modified_date', 'last_accessed_date'], excluded_llm_metadata_keys=['file_name', 'file_type', 'file_size', 'creation_date', 'last_modified_date', 'last_accessed_date'], relationships={}, text='length nis smaller than the representation dimensionality d, which is most often the case with\\nsentence representations used by state-of-the-art models in machine translations, such as word-piece\\n[38] and byte-pair [ 31] representations. To improve computational performance for tasks involving\\nvery long sequences, self-attention could be restricted to considering only a neighborhood of size rin\\nthe input sequence centered around the respective output position. This would increase the maximum\\npath length to O(n/r). We plan to investigate this approach further in future work.\\nA single convolutional layer with kernel width k < n does not connect all pairs of input and output\\npositions. Doing so requires a stack of O(n/k)convolutional layers in the case of contiguous kernels,\\norO(logk(n))in the case of dilated convolutions [ 18], increasing the length of the longest paths\\nbetween any two positions in the network. Convolutional layers are generally more expensive than\\nrecurrent layers, by a factor of k. Separable convolutions [ 6], however, decrease the complexity\\nconsiderably, to O(k·n·d+n·d2). Even with k=n, however, the complexity of a separable\\nconvolution is equal to the combination of a self-attention layer and a point-wise feed-forward layer,\\nthe approach we take in our model.\\nAs side benefit, self-attention could yield more interpretable models. We inspect attention distributions\\nfrom our models and present and discuss examples in the appendix. Not only do individual attention\\nheads clearly learn to perform different tasks, many appear to exhibit behavior related to the syntactic\\nand semantic structure of the sentences.\\n5 Training\\nThis section describes the training regime for our models.\\n5.1 Training Data and Batching\\nWe trained on the standard WMT 2014 English-German dataset consisting of about 4.5 million\\nsentence pairs. Sentences were encoded using byte-pair encoding [ 3], which has a shared source-\\ntarget vocabulary of about 37000 tokens. For English-French, we used the significantly larger WMT\\n2014 English-French dataset consisting of 36M sentences and split tokens into a 32000 word-piece\\nvocabulary [ 38]. Sentence pairs were batched together by approximate sequence length. Each training\\nbatch contained a set of sentence pairs containing approximately 25000 source tokens and 25000\\ntarget tokens.\\n5.2 Hardware and Schedule\\nWe trained our models on one machine with 8 NVIDIA P100 GPUs. For our base models using\\nthe hyperparameters described throughout the paper, each training step took about 0.4 seconds. We\\ntrained the base models for a total of 100,000 steps or 12 hours. For our big models,(described on the\\nbottom line of table 3), step time was 1.0 seconds. The big models were trained for 300,000 steps\\n(3.5 days).\\n5.3 Optimizer\\nWe used the Adam optimizer [ 20] with β1= 0.9,β2= 0.98andϵ= 10−9. We varied the learning\\nrate over the course of training, according to the formula:\\nlrate =d−0.5\\nmodel·min(step_num−0.5, step _num·warmup _steps−1.5) (3)\\nThis corresponds to increasing the learning rate linearly for the first warmup _steps training steps,\\nand decreasing it thereafter proportionally to the inverse square root of the step number. We used\\nwarmup _steps = 4000 .\\n5.4 Regularization\\nWe employ three types of regularization during training:\\n7', start_char_idx=None, end_char_idx=None, text_template='{metadata_str}\\n\\n{content}', metadata_template='{key}: {value}', metadata_seperator='\\n'),\n", 61 | " Document(id_='8894d3c1-3b30-48ed-a1be-270e87242ea5', embedding=None, metadata={'page_label': '8', 'file_name': 'attention.pdf', 'file_path': 'data\\\\attention.pdf', 'file_type': 'application/pdf', 'file_size': 2215244, 'creation_date': '2024-01-29', 'last_modified_date': '2024-01-29', 'last_accessed_date': '2024-01-29'}, excluded_embed_metadata_keys=['file_name', 'file_type', 'file_size', 'creation_date', 'last_modified_date', 'last_accessed_date'], excluded_llm_metadata_keys=['file_name', 'file_type', 'file_size', 'creation_date', 'last_modified_date', 'last_accessed_date'], relationships={}, text='Table 2: The Transformer achieves better BLEU scores than previous state-of-the-art models on the\\nEnglish-to-German and English-to-French newstest2014 tests at a fraction of the training cost.\\nModelBLEU Training Cost (FLOPs)\\nEN-DE EN-FR EN-DE EN-FR\\nByteNet [18] 23.75\\nDeep-Att + PosUnk [39] 39.2 1.0·1020\\nGNMT + RL [38] 24.6 39.92 2.3·10191.4·1020\\nConvS2S [9] 25.16 40.46 9.6·10181.5·1020\\nMoE [32] 26.03 40.56 2.0·10191.2·1020\\nDeep-Att + PosUnk Ensemble [39] 40.4 8.0·1020\\nGNMT + RL Ensemble [38] 26.30 41.16 1.8·10201.1·1021\\nConvS2S Ensemble [9] 26.36 41.29 7.7·10191.2·1021\\nTransformer (base model) 27.3 38.1 3.3·1018\\nTransformer (big) 28.4 41.8 2.3·1019\\nResidual Dropout We apply dropout [ 33] to the output of each sub-layer, before it is added to the\\nsub-layer input and normalized. In addition, we apply dropout to the sums of the embeddings and the\\npositional encodings in both the encoder and decoder stacks. For the base model, we use a rate of\\nPdrop= 0.1.\\nLabel Smoothing During training, we employed label smoothing of value ϵls= 0.1[36]. This\\nhurts perplexity, as the model learns to be more unsure, but improves accuracy and BLEU score.\\n6 Results\\n6.1 Machine Translation\\nOn the WMT 2014 English-to-German translation task, the big transformer model (Transformer (big)\\nin Table 2) outperforms the best previously reported models (including ensembles) by more than 2.0\\nBLEU, establishing a new state-of-the-art BLEU score of 28.4. The configuration of this model is\\nlisted in the bottom line of Table 3. Training took 3.5days on 8P100 GPUs. Even our base model\\nsurpasses all previously published models and ensembles, at a fraction of the training cost of any of\\nthe competitive models.\\nOn the WMT 2014 English-to-French translation task, our big model achieves a BLEU score of 41.0,\\noutperforming all of the previously published single models, at less than 1/4the training cost of the\\nprevious state-of-the-art model. The Transformer (big) model trained for English-to-French used\\ndropout rate Pdrop= 0.1, instead of 0.3.\\nFor the base models, we used a single model obtained by averaging the last 5 checkpoints, which\\nwere written at 10-minute intervals. For the big models, we averaged the last 20 checkpoints. We\\nused beam search with a beam size of 4and length penalty α= 0.6[38]. These hyperparameters\\nwere chosen after experimentation on the development set. We set the maximum output length during\\ninference to input length + 50, but terminate early when possible [38].\\nTable 2 summarizes our results and compares our translation quality and training costs to other model\\narchitectures from the literature. We estimate the number of floating point operations used to train a\\nmodel by multiplying the training time, the number of GPUs used, and an estimate of the sustained\\nsingle-precision floating-point capacity of each GPU5.\\n6.2 Model Variations\\nTo evaluate the importance of different components of the Transformer, we varied our base model\\nin different ways, measuring the change in performance on English-to-German translation on the\\n5We used values of 2.8, 3.7, 6.0 and 9.5 TFLOPS for K80, K40, M40 and P100, respectively.\\n8', start_char_idx=None, end_char_idx=None, text_template='{metadata_str}\\n\\n{content}', metadata_template='{key}: {value}', metadata_seperator='\\n'),\n", 62 | " Document(id_='19069f4d-73ce-4622-bd69-adf271645f6c', embedding=None, metadata={'page_label': '9', 'file_name': 'attention.pdf', 'file_path': 'data\\\\attention.pdf', 'file_type': 'application/pdf', 'file_size': 2215244, 'creation_date': '2024-01-29', 'last_modified_date': '2024-01-29', 'last_accessed_date': '2024-01-29'}, excluded_embed_metadata_keys=['file_name', 'file_type', 'file_size', 'creation_date', 'last_modified_date', 'last_accessed_date'], excluded_llm_metadata_keys=['file_name', 'file_type', 'file_size', 'creation_date', 'last_modified_date', 'last_accessed_date'], relationships={}, text='Table 3: Variations on the Transformer architecture. Unlisted values are identical to those of the base\\nmodel. All metrics are on the English-to-German translation development set, newstest2013. Listed\\nperplexities are per-wordpiece, according to our byte-pair encoding, and should not be compared to\\nper-word perplexities.\\nN d model dff h d k dvPdrop ϵlstrain PPL BLEU params\\nsteps (dev) (dev) ×106\\nbase 6 512 2048 8 64 64 0.1 0.1 100K 4.92 25.8 65\\n(A)1 512 512 5.29 24.9\\n4 128 128 5.00 25.5\\n16 32 32 4.91 25.8\\n32 16 16 5.01 25.4\\n(B)16 5.16 25.1 58\\n32 5.01 25.4 60\\n(C)2 6.11 23.7 36\\n4 5.19 25.3 50\\n8 4.88 25.5 80\\n256 32 32 5.75 24.5 28\\n1024 128 128 4.66 26.0 168\\n1024 5.12 25.4 53\\n4096 4.75 26.2 90\\n(D)0.0 5.77 24.6\\n0.2 4.95 25.5\\n0.0 4.67 25.3\\n0.2 5.47 25.7\\n(E) positional embedding instead of sinusoids 4.92 25.7\\nbig 6 1024 4096 16 0.3 300K 4.33 26.4 213\\ndevelopment set, newstest2013. We used beam search as described in the previous section, but no\\ncheckpoint averaging. We present these results in Table 3.\\nIn Table 3 rows (A), we vary the number of attention heads and the attention key and value dimensions,\\nkeeping the amount of computation constant, as described in Section 3.2.2. While single-head\\nattention is 0.9 BLEU worse than the best setting, quality also drops off with too many heads.\\nIn Table 3 rows (B), we observe that reducing the attention key size dkhurts model quality. This\\nsuggests that determining compatibility is not easy and that a more sophisticated compatibility\\nfunction than dot product may be beneficial. We further observe in rows (C) and (D) that, as expected,\\nbigger models are better, and dropout is very helpful in avoiding over-fitting. In row (E) we replace our\\nsinusoidal positional encoding with learned positional embeddings [ 9], and observe nearly identical\\nresults to the base model.\\n6.3 English Constituency Parsing\\nTo evaluate if the Transformer can generalize to other tasks we performed experiments on English\\nconstituency parsing. This task presents specific challenges: the output is subject to strong structural\\nconstraints and is significantly longer than the input. Furthermore, RNN sequence-to-sequence\\nmodels have not been able to attain state-of-the-art results in small-data regimes [37].\\nWe trained a 4-layer transformer with dmodel = 1024 on the Wall Street Journal (WSJ) portion of the\\nPenn Treebank [ 25], about 40K training sentences. We also trained it in a semi-supervised setting,\\nusing the larger high-confidence and BerkleyParser corpora from with approximately 17M sentences\\n[37]. We used a vocabulary of 16K tokens for the WSJ only setting and a vocabulary of 32K tokens\\nfor the semi-supervised setting.\\nWe performed only a small number of experiments to select the dropout, both attention and residual\\n(section 5.4), learning rates and beam size on the Section 22 development set, all other parameters\\nremained unchanged from the English-to-German base translation model. During inference, we\\n9', start_char_idx=None, end_char_idx=None, text_template='{metadata_str}\\n\\n{content}', metadata_template='{key}: {value}', metadata_seperator='\\n'),\n", 63 | " Document(id_='f1e8ae33-84e2-4040-aae6-189873b63c05', embedding=None, metadata={'page_label': '10', 'file_name': 'attention.pdf', 'file_path': 'data\\\\attention.pdf', 'file_type': 'application/pdf', 'file_size': 2215244, 'creation_date': '2024-01-29', 'last_modified_date': '2024-01-29', 'last_accessed_date': '2024-01-29'}, excluded_embed_metadata_keys=['file_name', 'file_type', 'file_size', 'creation_date', 'last_modified_date', 'last_accessed_date'], excluded_llm_metadata_keys=['file_name', 'file_type', 'file_size', 'creation_date', 'last_modified_date', 'last_accessed_date'], relationships={}, text='Table 4: The Transformer generalizes well to English constituency parsing (Results are on Section 23\\nof WSJ)\\nParser Training WSJ 23 F1\\nVinyals & Kaiser el al. (2014) [37] WSJ only, discriminative 88.3\\nPetrov et al. (2006) [29] WSJ only, discriminative 90.4\\nZhu et al. (2013) [40] WSJ only, discriminative 90.4\\nDyer et al. (2016) [8] WSJ only, discriminative 91.7\\nTransformer (4 layers) WSJ only, discriminative 91.3\\nZhu et al. (2013) [40] semi-supervised 91.3\\nHuang & Harper (2009) [14] semi-supervised 91.3\\nMcClosky et al. (2006) [26] semi-supervised 92.1\\nVinyals & Kaiser el al. (2014) [37] semi-supervised 92.1\\nTransformer (4 layers) semi-supervised 92.7\\nLuong et al. (2015) [23] multi-task 93.0\\nDyer et al. (2016) [8] generative 93.3\\nincreased the maximum output length to input length + 300. We used a beam size of 21andα= 0.3\\nfor both WSJ only and the semi-supervised setting.\\nOur results in Table 4 show that despite the lack of task-specific tuning our model performs sur-\\nprisingly well, yielding better results than all previously reported models with the exception of the\\nRecurrent Neural Network Grammar [8].\\nIn contrast to RNN sequence-to-sequence models [ 37], the Transformer outperforms the Berkeley-\\nParser [29] even when training only on the WSJ training set of 40K sentences.\\n7 Conclusion\\nIn this work, we presented the Transformer, the first sequence transduction model based entirely on\\nattention, replacing the recurrent layers most commonly used in encoder-decoder architectures with\\nmulti-headed self-attention.\\nFor translation tasks, the Transformer can be trained significantly faster than architectures based\\non recurrent or convolutional layers. On both WMT 2014 English-to-German and WMT 2014\\nEnglish-to-French translation tasks, we achieve a new state of the art. In the former task our best\\nmodel outperforms even all previously reported ensembles.\\nWe are excited about the future of attention-based models and plan to apply them to other tasks. We\\nplan to extend the Transformer to problems involving input and output modalities other than text and\\nto investigate local, restricted attention mechanisms to efficiently handle large inputs and outputs\\nsuch as images, audio and video. Making generation less sequential is another research goals of ours.\\nThe code we used to train and evaluate our models is available at https://github.com/\\ntensorflow/tensor2tensor .\\nAcknowledgements We are grateful to Nal Kalchbrenner and Stephan Gouws for their fruitful\\ncomments, corrections and inspiration.\\nReferences\\n[1]Jimmy Lei Ba, Jamie Ryan Kiros, and Geoffrey E Hinton. Layer normalization. arXiv preprint\\narXiv:1607.06450 , 2016.\\n[2]Dzmitry Bahdanau, Kyunghyun Cho, and Yoshua Bengio. Neural machine translation by jointly\\nlearning to align and translate. CoRR , abs/1409.0473, 2014.\\n[3]Denny Britz, Anna Goldie, Minh-Thang Luong, and Quoc V . Le. Massive exploration of neural\\nmachine translation architectures. CoRR , abs/1703.03906, 2017.\\n[4]Jianpeng Cheng, Li Dong, and Mirella Lapata. Long short-term memory-networks for machine\\nreading. arXiv preprint arXiv:1601.06733 , 2016.\\n10', start_char_idx=None, end_char_idx=None, text_template='{metadata_str}\\n\\n{content}', metadata_template='{key}: {value}', metadata_seperator='\\n'),\n", 64 | " Document(id_='b8570b24-f55c-46cd-9151-138219ec8c53', embedding=None, metadata={'page_label': '11', 'file_name': 'attention.pdf', 'file_path': 'data\\\\attention.pdf', 'file_type': 'application/pdf', 'file_size': 2215244, 'creation_date': '2024-01-29', 'last_modified_date': '2024-01-29', 'last_accessed_date': '2024-01-29'}, excluded_embed_metadata_keys=['file_name', 'file_type', 'file_size', 'creation_date', 'last_modified_date', 'last_accessed_date'], excluded_llm_metadata_keys=['file_name', 'file_type', 'file_size', 'creation_date', 'last_modified_date', 'last_accessed_date'], relationships={}, text='[5]Kyunghyun Cho, Bart van Merrienboer, Caglar Gulcehre, Fethi Bougares, Holger Schwenk,\\nand Yoshua Bengio. Learning phrase representations using rnn encoder-decoder for statistical\\nmachine translation. CoRR , abs/1406.1078, 2014.\\n[6]Francois Chollet. Xception: Deep learning with depthwise separable convolutions. arXiv\\npreprint arXiv:1610.02357 , 2016.\\n[7]Junyoung Chung, Çaglar Gülçehre, Kyunghyun Cho, and Yoshua Bengio. Empirical evaluation\\nof gated recurrent neural networks on sequence modeling. CoRR , abs/1412.3555, 2014.\\n[8]Chris Dyer, Adhiguna Kuncoro, Miguel Ballesteros, and Noah A. Smith. Recurrent neural\\nnetwork grammars. In Proc. of NAACL , 2016.\\n[9]Jonas Gehring, Michael Auli, David Grangier, Denis Yarats, and Yann N. Dauphin. Convolu-\\ntional sequence to sequence learning. arXiv preprint arXiv:1705.03122v2 , 2017.\\n[10] Alex Graves. Generating sequences with recurrent neural networks. arXiv preprint\\narXiv:1308.0850 , 2013.\\n[11] Kaiming He, Xiangyu Zhang, Shaoqing Ren, and Jian Sun. Deep residual learning for im-\\nage recognition. In Proceedings of the IEEE Conference on Computer Vision and Pattern\\nRecognition , pages 770–778, 2016.\\n[12] Sepp Hochreiter, Yoshua Bengio, Paolo Frasconi, and Jürgen Schmidhuber. Gradient flow in\\nrecurrent nets: the difficulty of learning long-term dependencies, 2001.\\n[13] Sepp Hochreiter and Jürgen Schmidhuber. Long short-term memory. Neural computation ,\\n9(8):1735–1780, 1997.\\n[14] Zhongqiang Huang and Mary Harper. Self-training PCFG grammars with latent annotations\\nacross languages. In Proceedings of the 2009 Conference on Empirical Methods in Natural\\nLanguage Processing , pages 832–841. ACL, August 2009.\\n[15] Rafal Jozefowicz, Oriol Vinyals, Mike Schuster, Noam Shazeer, and Yonghui Wu. Exploring\\nthe limits of language modeling. arXiv preprint arXiv:1602.02410 , 2016.\\n[16] Łukasz Kaiser and Samy Bengio. Can active memory replace attention? In Advances in Neural\\nInformation Processing Systems, (NIPS) , 2016.\\n[17] Łukasz Kaiser and Ilya Sutskever. Neural GPUs learn algorithms. In International Conference\\non Learning Representations (ICLR) , 2016.\\n[18] Nal Kalchbrenner, Lasse Espeholt, Karen Simonyan, Aaron van den Oord, Alex Graves, and Ko-\\nray Kavukcuoglu. Neural machine translation in linear time. arXiv preprint arXiv:1610.10099v2 ,\\n2017.\\n[19] Yoon Kim, Carl Denton, Luong Hoang, and Alexander M. Rush. Structured attention networks.\\nInInternational Conference on Learning Representations , 2017.\\n[20] Diederik Kingma and Jimmy Ba. Adam: A method for stochastic optimization. In ICLR , 2015.\\n[21] Oleksii Kuchaiev and Boris Ginsburg. Factorization tricks for LSTM networks. arXiv preprint\\narXiv:1703.10722 , 2017.\\n[22] Zhouhan Lin, Minwei Feng, Cicero Nogueira dos Santos, Mo Yu, Bing Xiang, Bowen\\nZhou, and Yoshua Bengio. A structured self-attentive sentence embedding. arXiv preprint\\narXiv:1703.03130 , 2017.\\n[23] Minh-Thang Luong, Quoc V . Le, Ilya Sutskever, Oriol Vinyals, and Lukasz Kaiser. Multi-task\\nsequence to sequence learning. arXiv preprint arXiv:1511.06114 , 2015.\\n[24] Minh-Thang Luong, Hieu Pham, and Christopher D Manning. Effective approaches to attention-\\nbased neural machine translation. arXiv preprint arXiv:1508.04025 , 2015.\\n11', start_char_idx=None, end_char_idx=None, text_template='{metadata_str}\\n\\n{content}', metadata_template='{key}: {value}', metadata_seperator='\\n'),\n", 65 | " Document(id_='5552287c-3b99-432d-81fc-fbe0f57ca4ff', embedding=None, metadata={'page_label': '12', 'file_name': 'attention.pdf', 'file_path': 'data\\\\attention.pdf', 'file_type': 'application/pdf', 'file_size': 2215244, 'creation_date': '2024-01-29', 'last_modified_date': '2024-01-29', 'last_accessed_date': '2024-01-29'}, excluded_embed_metadata_keys=['file_name', 'file_type', 'file_size', 'creation_date', 'last_modified_date', 'last_accessed_date'], excluded_llm_metadata_keys=['file_name', 'file_type', 'file_size', 'creation_date', 'last_modified_date', 'last_accessed_date'], relationships={}, text='[25] Mitchell P Marcus, Mary Ann Marcinkiewicz, and Beatrice Santorini. Building a large annotated\\ncorpus of english: The penn treebank. Computational linguistics , 19(2):313–330, 1993.\\n[26] David McClosky, Eugene Charniak, and Mark Johnson. Effective self-training for parsing. In\\nProceedings of the Human Language Technology Conference of the NAACL, Main Conference ,\\npages 152–159. ACL, June 2006.\\n[27] Ankur Parikh, Oscar Täckström, Dipanjan Das, and Jakob Uszkoreit. A decomposable attention\\nmodel. In Empirical Methods in Natural Language Processing , 2016.\\n[28] Romain Paulus, Caiming Xiong, and Richard Socher. A deep reinforced model for abstractive\\nsummarization. arXiv preprint arXiv:1705.04304 , 2017.\\n[29] Slav Petrov, Leon Barrett, Romain Thibaux, and Dan Klein. Learning accurate, compact,\\nand interpretable tree annotation. In Proceedings of the 21st International Conference on\\nComputational Linguistics and 44th Annual Meeting of the ACL , pages 433–440. ACL, July\\n2006.\\n[30] Ofir Press and Lior Wolf. Using the output embedding to improve language models. arXiv\\npreprint arXiv:1608.05859 , 2016.\\n[31] Rico Sennrich, Barry Haddow, and Alexandra Birch. Neural machine translation of rare words\\nwith subword units. arXiv preprint arXiv:1508.07909 , 2015.\\n[32] Noam Shazeer, Azalia Mirhoseini, Krzysztof Maziarz, Andy Davis, Quoc Le, Geoffrey Hinton,\\nand Jeff Dean. Outrageously large neural networks: The sparsely-gated mixture-of-experts\\nlayer. arXiv preprint arXiv:1701.06538 , 2017.\\n[33] Nitish Srivastava, Geoffrey E Hinton, Alex Krizhevsky, Ilya Sutskever, and Ruslan Salakhutdi-\\nnov. Dropout: a simple way to prevent neural networks from overfitting. Journal of Machine\\nLearning Research , 15(1):1929–1958, 2014.\\n[34] Sainbayar Sukhbaatar, Arthur Szlam, Jason Weston, and Rob Fergus. End-to-end memory\\nnetworks. In C. Cortes, N. D. Lawrence, D. D. Lee, M. Sugiyama, and R. Garnett, editors,\\nAdvances in Neural Information Processing Systems 28 , pages 2440–2448. Curran Associates,\\nInc., 2015.\\n[35] Ilya Sutskever, Oriol Vinyals, and Quoc VV Le. Sequence to sequence learning with neural\\nnetworks. In Advances in Neural Information Processing Systems , pages 3104–3112, 2014.\\n[36] Christian Szegedy, Vincent Vanhoucke, Sergey Ioffe, Jonathon Shlens, and Zbigniew Wojna.\\nRethinking the inception architecture for computer vision. CoRR , abs/1512.00567, 2015.\\n[37] Vinyals & Kaiser, Koo, Petrov, Sutskever, and Hinton. Grammar as a foreign language. In\\nAdvances in Neural Information Processing Systems , 2015.\\n[38] Yonghui Wu, Mike Schuster, Zhifeng Chen, Quoc V Le, Mohammad Norouzi, Wolfgang\\nMacherey, Maxim Krikun, Yuan Cao, Qin Gao, Klaus Macherey, et al. Google’s neural machine\\ntranslation system: Bridging the gap between human and machine translation. arXiv preprint\\narXiv:1609.08144 , 2016.\\n[39] Jie Zhou, Ying Cao, Xuguang Wang, Peng Li, and Wei Xu. Deep recurrent models with\\nfast-forward connections for neural machine translation. CoRR , abs/1606.04199, 2016.\\n[40] Muhua Zhu, Yue Zhang, Wenliang Chen, Min Zhang, and Jingbo Zhu. Fast and accurate\\nshift-reduce constituent parsing. In Proceedings of the 51st Annual Meeting of the ACL (Volume\\n1: Long Papers) , pages 434–443. ACL, August 2013.\\n12', start_char_idx=None, end_char_idx=None, text_template='{metadata_str}\\n\\n{content}', metadata_template='{key}: {value}', metadata_seperator='\\n'),\n", 66 | " Document(id_='8fe0fc0f-a5e1-4881-a434-5b36ae9cb342', embedding=None, metadata={'page_label': '13', 'file_name': 'attention.pdf', 'file_path': 'data\\\\attention.pdf', 'file_type': 'application/pdf', 'file_size': 2215244, 'creation_date': '2024-01-29', 'last_modified_date': '2024-01-29', 'last_accessed_date': '2024-01-29'}, excluded_embed_metadata_keys=['file_name', 'file_type', 'file_size', 'creation_date', 'last_modified_date', 'last_accessed_date'], excluded_llm_metadata_keys=['file_name', 'file_type', 'file_size', 'creation_date', 'last_modified_date', 'last_accessed_date'], relationships={}, text='Attention Visualizations\\nInput-Input Layer5\\nIt\\nis\\nin\\nthis\\nspirit\\nthat\\na\\nmajority\\nof\\nAmerican\\ngovernments\\nhave\\npassed\\nnew\\nlaws\\nsince\\n2009\\nmaking\\nthe\\nregistration\\nor\\nvoting\\nprocess\\nmore\\ndifficult\\n.\\n\\n\\n\\n\\n\\n\\n\\nIt\\nis\\nin\\nthis\\nspirit\\nthat\\na\\nmajority\\nof\\nAmerican\\ngovernments\\nhave\\npassed\\nnew\\nlaws\\nsince\\n2009\\nmaking\\nthe\\nregistration\\nor\\nvoting\\nprocess\\nmore\\ndifficult\\n.\\n\\n\\n\\n\\n\\n\\n\\nFigure 3: An example of the attention mechanism following long-distance dependencies in the\\nencoder self-attention in layer 5 of 6. Many of the attention heads attend to a distant dependency of\\nthe verb ‘making’, completing the phrase ‘making...more difficult’. Attentions here shown only for\\nthe word ‘making’. Different colors represent different heads. Best viewed in color.\\n13', start_char_idx=None, end_char_idx=None, text_template='{metadata_str}\\n\\n{content}', metadata_template='{key}: {value}', metadata_seperator='\\n'),\n", 67 | " Document(id_='7d1f55f7-5346-4d3c-829c-b8310dc41eed', embedding=None, metadata={'page_label': '14', 'file_name': 'attention.pdf', 'file_path': 'data\\\\attention.pdf', 'file_type': 'application/pdf', 'file_size': 2215244, 'creation_date': '2024-01-29', 'last_modified_date': '2024-01-29', 'last_accessed_date': '2024-01-29'}, excluded_embed_metadata_keys=['file_name', 'file_type', 'file_size', 'creation_date', 'last_modified_date', 'last_accessed_date'], excluded_llm_metadata_keys=['file_name', 'file_type', 'file_size', 'creation_date', 'last_modified_date', 'last_accessed_date'], relationships={}, text='Input-Input Layer5\\nThe\\nLaw\\nwill\\nnever\\nbe\\nperfect\\n,\\nbut\\nits\\napplication\\nshould\\nbe\\njust\\n-\\nthis\\nis\\nwhat\\nwe\\nare\\nmissing\\n,\\nin\\nmy\\nopinion\\n.\\n\\n\\nThe\\nLaw\\nwill\\nnever\\nbe\\nperfect\\n,\\nbut\\nits\\napplication\\nshould\\nbe\\njust\\n-\\nthis\\nis\\nwhat\\nwe\\nare\\nmissing\\n,\\nin\\nmy\\nopinion\\n.\\n\\n\\nInput-Input Layer5\\nThe\\nLaw\\nwill\\nnever\\nbe\\nperfect\\n,\\nbut\\nits\\napplication\\nshould\\nbe\\njust\\n-\\nthis\\nis\\nwhat\\nwe\\nare\\nmissing\\n,\\nin\\nmy\\nopinion\\n.\\n\\n\\nThe\\nLaw\\nwill\\nnever\\nbe\\nperfect\\n,\\nbut\\nits\\napplication\\nshould\\nbe\\njust\\n-\\nthis\\nis\\nwhat\\nwe\\nare\\nmissing\\n,\\nin\\nmy\\nopinion\\n.\\n\\nFigure 4: Two attention heads, also in layer 5 of 6, apparently involved in anaphora resolution. Top:\\nFull attentions for head 5. Bottom: Isolated attentions from just the word ‘its’ for attention heads 5\\nand 6. Note that the attentions are very sharp for this word.\\n14', start_char_idx=None, end_char_idx=None, text_template='{metadata_str}\\n\\n{content}', metadata_template='{key}: {value}', metadata_seperator='\\n'),\n", 68 | " Document(id_='ca463891-08a7-498c-8d4e-d179a47f1743', embedding=None, metadata={'page_label': '15', 'file_name': 'attention.pdf', 'file_path': 'data\\\\attention.pdf', 'file_type': 'application/pdf', 'file_size': 2215244, 'creation_date': '2024-01-29', 'last_modified_date': '2024-01-29', 'last_accessed_date': '2024-01-29'}, excluded_embed_metadata_keys=['file_name', 'file_type', 'file_size', 'creation_date', 'last_modified_date', 'last_accessed_date'], excluded_llm_metadata_keys=['file_name', 'file_type', 'file_size', 'creation_date', 'last_modified_date', 'last_accessed_date'], relationships={}, text='Input-Input Layer5\\nThe\\nLaw\\nwill\\nnever\\nbe\\nperfect\\n,\\nbut\\nits\\napplication\\nshould\\nbe\\njust\\n-\\nthis\\nis\\nwhat\\nwe\\nare\\nmissing\\n,\\nin\\nmy\\nopinion\\n.\\n\\n\\nThe\\nLaw\\nwill\\nnever\\nbe\\nperfect\\n,\\nbut\\nits\\napplication\\nshould\\nbe\\njust\\n-\\nthis\\nis\\nwhat\\nwe\\nare\\nmissing\\n,\\nin\\nmy\\nopinion\\n.\\n\\n\\nInput-Input Layer5\\nThe\\nLaw\\nwill\\nnever\\nbe\\nperfect\\n,\\nbut\\nits\\napplication\\nshould\\nbe\\njust\\n-\\nthis\\nis\\nwhat\\nwe\\nare\\nmissing\\n,\\nin\\nmy\\nopinion\\n.\\n\\n\\nThe\\nLaw\\nwill\\nnever\\nbe\\nperfect\\n,\\nbut\\nits\\napplication\\nshould\\nbe\\njust\\n-\\nthis\\nis\\nwhat\\nwe\\nare\\nmissing\\n,\\nin\\nmy\\nopinion\\n.\\n\\nFigure 5: Many of the attention heads exhibit behaviour that seems related to the structure of the\\nsentence. We give two such examples above, from two different heads from the encoder self-attention\\nat layer 5 of 6. The heads clearly learned to perform different tasks.\\n15', start_char_idx=None, end_char_idx=None, text_template='{metadata_str}\\n\\n{content}', metadata_template='{key}: {value}', metadata_seperator='\\n'),\n", 69 | " Document(id_='512696c6-573d-4c27-af21-3271d7bc519a', embedding=None, metadata={'page_label': '1', 'file_name': 'yolo.pdf', 'file_path': 'data\\\\yolo.pdf', 'file_type': 'application/pdf', 'file_size': 5296750, 'creation_date': '2024-01-29', 'last_modified_date': '2024-01-29', 'last_accessed_date': '2024-01-29'}, excluded_embed_metadata_keys=['file_name', 'file_type', 'file_size', 'creation_date', 'last_modified_date', 'last_accessed_date'], excluded_llm_metadata_keys=['file_name', 'file_type', 'file_size', 'creation_date', 'last_modified_date', 'last_accessed_date'], relationships={}, text='You Only Look Once:\\nUnified, Real-Time Object Detection\\nJoseph Redmon∗, Santosh Divvala∗†, Ross Girshick¶, Ali Farhadi∗†\\nUniversity of Washington∗, Allen Institute for AI†, Facebook AI Research¶\\nhttp://pjreddie.com/yolo/\\nAbstract\\nWe present YOLO, a new approach to object detection.\\nPrior work on object detection repurposes classifiers to per-\\nform detection. Instead, we frame object detection as a re-\\ngression problem to spatially separated bounding boxes and\\nassociated class probabilities. A single neural network pre-\\ndicts bounding boxes and class probabilities directly from\\nfull images in one evaluation. Since the whole detection\\npipeline is a single network, it can be optimized end-to-end\\ndirectly on detection performance.\\nOur unified architecture is extremely fast. Our base\\nYOLO model processes images in real-time at 45 frames\\nper second. A smaller version of the network, Fast YOLO,\\nprocesses an astounding 155 frames per second while\\nstill achieving double the mAP of other real-time detec-\\ntors. Compared to state-of-the-art detection systems, YOLO\\nmakes more localization errors but is less likely to predict\\nfalse positives on background. Finally, YOLO learns very\\ngeneral representations of objects. It outperforms other de-\\ntection methods, including DPM and R-CNN, when gener-\\nalizing from natural images to other domains like artwork.\\n1. Introduction\\nHumans glance at an image and instantly know what ob-\\njects are in the image, where they are, and how they inter-\\nact. The human visual system is fast and accurate, allow-\\ning us to perform complex tasks like driving with little con-\\nscious thought. Fast, accurate algorithms for object detec-\\ntion would allow computers to drive cars without special-\\nized sensors, enable assistive devices to convey real-time\\nscene information to human users, and unlock the potential\\nfor general purpose, responsive robotic systems.\\nCurrent detection systems repurpose classifiers to per-\\nform detection. To detect an object, these systems take a\\nclassifier for that object and evaluate it at various locations\\nand scales in a test image. Systems like deformable parts\\nmodels (DPM) use a sliding window approach where the\\nclassifier is run at evenly spaced locations over the entire\\nimage [10].\\nMore recent approaches like R-CNN use region proposal\\n1. Resize image.\\n2. Run convolutional network.3. Non-max suppression.\\nDog: 0.30Person: 0.64Horse: 0.28Figure 1: The YOLO Detection System. Processing images\\nwith YOLO is simple and straightforward. Our system (1) resizes\\nthe input image to 448×448, (2) runs a single convolutional net-\\nwork on the image, and (3) thresholds the resulting detections by\\nthe model’s confidence.\\nmethods to first generate potential bounding boxes in an im-\\nage and then run a classifier on these proposed boxes. After\\nclassification, post-processing is used to refine the bound-\\ning boxes, eliminate duplicate detections, and rescore the\\nboxes based on other objects in the scene [13]. These com-\\nplex pipelines are slow and hard to optimize because each\\nindividual component must be trained separately.\\nWe reframe object detection as a single regression prob-\\nlem, straight from image pixels to bounding box coordi-\\nnates and class probabilities. Using our system, you only\\nlook once (YOLO) at an image to predict what objects are\\npresent and where they are.\\nYOLO is refreshingly simple: see Figure 1. A sin-\\ngle convolutional network simultaneously predicts multi-\\nple bounding boxes and class probabilities for those boxes.\\nYOLO trains on full images and directly optimizes detec-\\ntion performance. This unified model has several benefits\\nover traditional methods of object detection.\\nFirst, YOLO is extremely fast. Since we frame detection\\nas a regression problem we don’t need a complex pipeline.\\nWe simply run our neural network on a new image at test\\ntime to predict detections. Our base network runs at 45\\nframes per second with no batch processing on a Titan X\\nGPU and a fast version runs at more than 150 fps. This\\nmeans we can process streaming video in real-time with\\nless than 25 milliseconds of latency. Furthermore, YOLO\\nachieves more than twice the mean average precision of\\nother real-time systems. For a demo of our system running\\nin real-time on a webcam please see our project webpage:\\nhttp://pjreddie.com/yolo/ .\\nSecond, YOLO reasons globally about the image when\\n1arXiv:1506.02640v5 [cs.CV] 9 May 2016', start_char_idx=None, end_char_idx=None, text_template='{metadata_str}\\n\\n{content}', metadata_template='{key}: {value}', metadata_seperator='\\n'),\n", 70 | " Document(id_='04f972c7-edc3-4602-8f0c-8294eddbdf61', embedding=None, metadata={'page_label': '2', 'file_name': 'yolo.pdf', 'file_path': 'data\\\\yolo.pdf', 'file_type': 'application/pdf', 'file_size': 5296750, 'creation_date': '2024-01-29', 'last_modified_date': '2024-01-29', 'last_accessed_date': '2024-01-29'}, excluded_embed_metadata_keys=['file_name', 'file_type', 'file_size', 'creation_date', 'last_modified_date', 'last_accessed_date'], excluded_llm_metadata_keys=['file_name', 'file_type', 'file_size', 'creation_date', 'last_modified_date', 'last_accessed_date'], relationships={}, text='making predictions. Unlike sliding window and region\\nproposal-based techniques, YOLO sees the entire image\\nduring training and test time so it implicitly encodes contex-\\ntual information about classes as well as their appearance.\\nFast R-CNN, a top detection method [14], mistakes back-\\nground patches in an image for objects because it can’t see\\nthe larger context. YOLO makes less than half the number\\nof background errors compared to Fast R-CNN.\\nThird, YOLO learns generalizable representations of ob-\\njects. When trained on natural images and tested on art-\\nwork, YOLO outperforms top detection methods like DPM\\nand R-CNN by a wide margin. Since YOLO is highly gen-\\neralizable it is less likely to break down when applied to\\nnew domains or unexpected inputs.\\nYOLO still lags behind state-of-the-art detection systems\\nin accuracy. While it can quickly identify objects in im-\\nages it struggles to precisely localize some objects, espe-\\ncially small ones. We examine these tradeoffs further in our\\nexperiments.\\nAll of our training and testing code is open source. A\\nvariety of pretrained models are also available to download.\\n2. Unified Detection\\nWe unify the separate components of object detection\\ninto a single neural network. Our network uses features\\nfrom the entire image to predict each bounding box. It also\\npredicts all bounding boxes across all classes for an im-\\nage simultaneously. This means our network reasons glob-\\nally about the full image and all the objects in the image.\\nThe YOLO design enables end-to-end training and real-\\ntime speeds while maintaining high average precision.\\nOur system divides the input image into an S×Sgrid.\\nIf the center of an object falls into a grid cell, that grid cell\\nis responsible for detecting that object.\\nEach grid cell predicts Bbounding boxes and confidence\\nscores for those boxes. These confidence scores reflect how\\nconfident the model is that the box contains an object and\\nalso how accurate it thinks the box is that it predicts. For-\\nmally we define confidence as Pr(Object )∗IOUtruth\\npred. If no\\nobject exists in that cell, the confidence scores should be\\nzero. Otherwise we want the confidence score to equal the\\nintersection over union (IOU) between the predicted box\\nand the ground truth.\\nEach bounding box consists of 5 predictions: x,y,w,h,\\nand confidence. The (x,y)coordinates represent the center\\nof the box relative to the bounds of the grid cell. The width\\nand height are predicted relative to the whole image. Finally\\nthe confidence prediction represents the IOU between the\\npredicted box and any ground truth box.\\nEach grid cell also predicts Cconditional class proba-\\nbilities, Pr(Classi|Object ). These probabilities are condi-\\ntioned on the grid cell containing an object. We only predictone set of class probabilities per grid cell, regardless of the\\nnumber of boxes B.\\nAt test time we multiply the conditional class probabili-\\nties and the individual box confidence predictions,\\nPr(Classi|Object )∗Pr(Object )∗IOUtruth\\npred= Pr( Classi)∗IOUtruth\\npred(1)\\nwhich gives us class-specific confidence scores for each\\nbox. These scores encode both the probability of that class\\nappearing in the box and how well the predicted box fits the\\nobject.\\nS × S grid on inputBounding boxes + confidence\\nClass probability mapFinal detections\\nFigure 2: The Model. Our system models detection as a regres-\\nsion problem. It divides the image into an S×Sgrid and for each\\ngrid cell predicts Bbounding boxes, confidence for those boxes,\\nandCclass probabilities. These predictions are encoded as an\\nS×S×(B∗5 +C)tensor.\\nFor evaluating YOLO on P ASCAL VOC, we use S= 7,\\nB= 2. PASCAL VOC has 20 labelled classes so C= 20 .\\nOur final prediction is a 7×7×30tensor.\\n2.1. Network Design\\nWe implement this model as a convolutional neural net-\\nwork and evaluate it on the P ASCAL VOC detection dataset\\n[9]. The initial convolutional layers of the network extract\\nfeatures from the image while the fully connected layers\\npredict the output probabilities and coordinates.\\nOur network architecture is inspired by the GoogLeNet\\nmodel for image classification [34]. Our network has 24\\nconvolutional layers followed by 2 fully connected layers.\\nInstead of the inception modules used by GoogLeNet, we\\nsimply use 1×1reduction layers followed by 3×3convo-\\nlutional layers, similar to Lin et al [22]. The full network is\\nshown in Figure 3.\\nWe also train a fast version of YOLO designed to push\\nthe boundaries of fast object detection. Fast YOLO uses a\\nneural network with fewer convolutional layers (9 instead\\nof 24) and fewer filters in those layers. Other than the size\\nof the network, all training and testing parameters are the\\nsame between YOLO and Fast YOLO.', start_char_idx=None, end_char_idx=None, text_template='{metadata_str}\\n\\n{content}', metadata_template='{key}: {value}', metadata_seperator='\\n'),\n", 71 | " Document(id_='3e97a2f2-db10-4f37-b4a6-a221d924fbdd', embedding=None, metadata={'page_label': '3', 'file_name': 'yolo.pdf', 'file_path': 'data\\\\yolo.pdf', 'file_type': 'application/pdf', 'file_size': 5296750, 'creation_date': '2024-01-29', 'last_modified_date': '2024-01-29', 'last_accessed_date': '2024-01-29'}, excluded_embed_metadata_keys=['file_name', 'file_type', 'file_size', 'creation_date', 'last_modified_date', 'last_accessed_date'], excluded_llm_metadata_keys=['file_name', 'file_type', 'file_size', 'creation_date', 'last_modified_date', 'last_accessed_date'], relationships={}, text='448\\n448\\n3\\n7\\n7\\nConv. Layer\\n7x7x64-s-2\\nMaxpool Layer\\n2x2-s-2\\n3\\n3112\\n112\\n192\\n3\\n356\\n56\\n256\\nConn. Layer4096\\nConn. Layer Conv. Layer\\n3x3x192\\nMaxpool Layer\\n2x2-s-2Conv. Layers\\n1x1x128\\n3x3x256\\n1x1x256\\n3x3x512\\nMaxpool Layer\\n2x2-s-2\\n3\\n328\\n28\\n512\\nConv. Layers\\n1x1x256\\n3x3x5121x1x512\\n3x3x1024\\nMaxpool Layer\\n2x2-s-2\\n3\\n314\\n14\\n1024\\nConv. Layers\\n1x1x512\\n3x3x10243x3x1024\\n3x3x1024-s-2\\n3\\n37\\n7\\n10247\\n7\\n10247\\n7\\n30\\n} ×4 } ×2Conv. Layers\\n3x3x1024\\n3x3x1024Figure 3: The Architecture. Our detection network has 24 convolutional layers followed by 2 fully connected layers. Alternating 1×1\\nconvolutional layers reduce the features space from preceding layers. We pretrain the convolutional layers on the ImageNet classification\\ntask at half the resolution ( 224×224input image) and then double the resolution for detection.\\nThe final output of our network is the 7×7×30tensor\\nof predictions.\\n2.2. Training\\nWe pretrain our convolutional layers on the ImageNet\\n1000-class competition dataset [30]. For pretraining we use\\nthe first 20 convolutional layers from Figure 3 followed by a\\naverage-pooling layer and a fully connected layer. We train\\nthis network for approximately a week and achieve a single\\ncrop top-5 accuracy of 88% on the ImageNet 2012 valida-\\ntion set, comparable to the GoogLeNet models in Caffe’s\\nModel Zoo [24]. We use the Darknet framework for all\\ntraining and inference [26].\\nWe then convert the model to perform detection. Ren et\\nal. show that adding both convolutional and connected lay-\\ners to pretrained networks can improve performance [29].\\nFollowing their example, we add four convolutional lay-\\ners and two fully connected layers with randomly initialized\\nweights. Detection often requires fine-grained visual infor-\\nmation so we increase the input resolution of the network\\nfrom 224×224to448×448.\\nOur final layer predicts both class probabilities and\\nbounding box coordinates. We normalize the bounding box\\nwidth and height by the image width and height so that they\\nfall between 0 and 1. We parametrize the bounding box x\\nandycoordinates to be offsets of a particular grid cell loca-\\ntion so they are also bounded between 0 and 1.\\nWe use a linear activation function for the final layer and\\nall other layers use the following leaky rectified linear acti-\\nvation:\\nφ(x) ={\\nx, ifx>0\\n0.1x,otherwise(2)\\nWe optimize for sum-squared error in the output of ourmodel. We use sum-squared error because it is easy to op-\\ntimize, however it does not perfectly align with our goal of\\nmaximizing average precision. It weights localization er-\\nror equally with classification error which may not be ideal.\\nAlso, in every image many grid cells do not contain any\\nobject. This pushes the “confidence” scores of those cells\\ntowards zero, often overpowering the gradient from cells\\nthat do contain objects. This can lead to model instability,\\ncausing training to diverge early on.\\nTo remedy this, we increase the loss from bounding box\\ncoordinate predictions and decrease the loss from confi-\\ndence predictions for boxes that don’t contain objects. We\\nuse two parameters, λcoordandλnoobjto accomplish this. We\\nsetλcoord= 5andλnoobj=.5.\\nSum-squared error also equally weights errors in large\\nboxes and small boxes. Our error metric should reflect that\\nsmall deviations in large boxes matter less than in small\\nboxes. To partially address this we predict the square root\\nof the bounding box width and height instead of the width\\nand height directly.\\nYOLO predicts multiple bounding boxes per grid cell.\\nAt training time we only want one bounding box predictor\\nto be responsible for each object. We assign one predictor\\nto be “responsible” for predicting an object based on which\\nprediction has the highest current IOU with the ground\\ntruth. This leads to specialization between the bounding box\\npredictors. Each predictor gets better at predicting certain\\nsizes, aspect ratios, or classes of object, improving overall\\nrecall.\\nDuring training we optimize the following, multi-part', start_char_idx=None, end_char_idx=None, text_template='{metadata_str}\\n\\n{content}', metadata_template='{key}: {value}', metadata_seperator='\\n'),\n", 72 | " Document(id_='c4e2361f-5a48-4e66-b92a-5ef28be385cb', embedding=None, metadata={'page_label': '4', 'file_name': 'yolo.pdf', 'file_path': 'data\\\\yolo.pdf', 'file_type': 'application/pdf', 'file_size': 5296750, 'creation_date': '2024-01-29', 'last_modified_date': '2024-01-29', 'last_accessed_date': '2024-01-29'}, excluded_embed_metadata_keys=['file_name', 'file_type', 'file_size', 'creation_date', 'last_modified_date', 'last_accessed_date'], excluded_llm_metadata_keys=['file_name', 'file_type', 'file_size', 'creation_date', 'last_modified_date', 'last_accessed_date'], relationships={}, text='loss function:\\nλcoordS2∑\\ni=0B∑\\nj=01obj\\nij[\\n(xi−ˆxi)2+ (yi−ˆyi)2]\\n+λcoordS2∑\\ni=0B∑\\nj=01obj\\nij[(√wi−√\\nˆwi)2+(√\\nhi−√\\nˆhi)2]\\n+S2∑\\ni=0B∑\\nj=01obj\\nij(\\nCi−ˆCi)2\\n+λnoobjS2∑\\ni=0B∑\\nj=01noobj\\nij(\\nCi−ˆCi)2\\n+S2∑\\ni=01obj\\ni∑\\nc∈classes(pi(c)−ˆpi(c))2(3)\\nwhere 1obj\\nidenotes if object appears in cell iand 1obj\\nijde-\\nnotes that the jth bounding box predictor in cell iis “re-\\nsponsible” for that prediction.\\nNote that the loss function only penalizes classification\\nerror if an object is present in that grid cell (hence the con-\\nditional class probability discussed earlier). It also only pe-\\nnalizes bounding box coordinate error if that predictor is\\n“responsible” for the ground truth box (i.e. has the highest\\nIOU of any predictor in that grid cell).\\nWe train the network for about 135 epochs on the train-\\ning and validation data sets from P ASCAL VOC 2007 and\\n2012. When testing on 2012 we also include the VOC 2007\\ntest data for training. Throughout training we use a batch\\nsize of 64, a momentum of 0.9and a decay of 0.0005 .\\nOur learning rate schedule is as follows: For the first\\nepochs we slowly raise the learning rate from 10−3to10−2.\\nIf we start at a high learning rate our model often diverges\\ndue to unstable gradients. We continue training with 10−2\\nfor 75 epochs, then 10−3for 30 epochs, and finally 10−4\\nfor 30 epochs.\\nTo avoid overfitting we use dropout and extensive data\\naugmentation. A dropout layer with rate = .5 after the first\\nconnected layer prevents co-adaptation between layers [18].\\nFor data augmentation we introduce random scaling and\\ntranslations of up to 20% of the original image size. We\\nalso randomly adjust the exposure and saturation of the im-\\nage by up to a factor of 1.5in the HSV color space.\\n2.3. Inference\\nJust like in training, predicting detections for a test image\\nonly requires one network evaluation. On P ASCAL VOC the\\nnetwork predicts 98 bounding boxes per image and class\\nprobabilities for each box. YOLO is extremely fast at test\\ntime since it only requires a single network evaluation, un-\\nlike classifier-based methods.\\nThe grid design enforces spatial diversity in the bound-\\ning box predictions. Often it is clear which grid cell an\\nobject falls in to and the network only predicts one box for\\neach object. However, some large objects or objects nearthe border of multiple cells can be well localized by multi-\\nple cells. Non-maximal suppression can be used to fix these\\nmultiple detections. While not critical to performance as it\\nis for R-CNN or DPM, non-maximal suppression adds 2-\\n3% in mAP.\\n2.4. Limitations of YOLO\\nYOLO imposes strong spatial constraints on bounding\\nbox predictions since each grid cell only predicts two boxes\\nand can only have one class. This spatial constraint lim-\\nits the number of nearby objects that our model can pre-\\ndict. Our model struggles with small objects that appear in\\ngroups, such as flocks of birds.\\nSince our model learns to predict bounding boxes from\\ndata, it struggles to generalize to objects in new or unusual\\naspect ratios or configurations. Our model also uses rela-\\ntively coarse features for predicting bounding boxes since\\nour architecture has multiple downsampling layers from the\\ninput image.\\nFinally, while we train on a loss function that approxi-\\nmates detection performance, our loss function treats errors\\nthe same in small bounding boxes versus large bounding\\nboxes. A small error in a large box is generally benign but a\\nsmall error in a small box has a much greater effect on IOU.\\nOur main source of error is incorrect localizations.\\n3. Comparison to Other Detection Systems\\nObject detection is a core problem in computer vision.\\nDetection pipelines generally start by extracting a set of\\nrobust features from input images (Haar [25], SIFT [23],\\nHOG [4], convolutional features [6]). Then, classifiers\\n[36, 21, 13, 10] or localizers [1, 32] are used to identify\\nobjects in the feature space. These classifiers or localizers\\nare run either in sliding window fashion over the whole im-\\nage or on some subset of regions in the image [35, 15, 39].\\nWe compare the YOLO detection system to several top de-\\ntection frameworks, highlighting key similarities and differ-\\nences.\\nDeformable parts models. Deformable parts models\\n(DPM) use a sliding window approach to object detection\\n[10]. DPM uses a disjoint pipeline to extract static features,\\nclassify regions, predict bounding boxes for high scoring\\nregions, etc. Our system replaces all of these disparate parts\\nwith a single convolutional neural network. The network\\nperforms feature extraction, bounding box prediction, non-\\nmaximal suppression, and contextual reasoning all concur-\\nrently. Instead of static features, the network trains the fea-\\ntures in-line and optimizes them for the detection task. Our\\nunified architecture leads to a faster, more accurate model\\nthan DPM.\\nR-CNN. R-CNN and its variants use region proposals in-\\nstead of sliding windows to find objects in images. Selective', start_char_idx=None, end_char_idx=None, text_template='{metadata_str}\\n\\n{content}', metadata_template='{key}: {value}', metadata_seperator='\\n'),\n", 73 | " Document(id_='b9536b43-b935-4c29-8a71-787a0d321d51', embedding=None, metadata={'page_label': '5', 'file_name': 'yolo.pdf', 'file_path': 'data\\\\yolo.pdf', 'file_type': 'application/pdf', 'file_size': 5296750, 'creation_date': '2024-01-29', 'last_modified_date': '2024-01-29', 'last_accessed_date': '2024-01-29'}, excluded_embed_metadata_keys=['file_name', 'file_type', 'file_size', 'creation_date', 'last_modified_date', 'last_accessed_date'], excluded_llm_metadata_keys=['file_name', 'file_type', 'file_size', 'creation_date', 'last_modified_date', 'last_accessed_date'], relationships={}, text='Search [35] generates potential bounding boxes, a convolu-\\ntional network extracts features, an SVM scores the boxes, a\\nlinear model adjusts the bounding boxes, and non-max sup-\\npression eliminates duplicate detections. Each stage of this\\ncomplex pipeline must be precisely tuned independently\\nand the resulting system is very slow, taking more than 40\\nseconds per image at test time [14].\\nYOLO shares some similarities with R-CNN. Each grid\\ncell proposes potential bounding boxes and scores those\\nboxes using convolutional features. However, our system\\nputs spatial constraints on the grid cell proposals which\\nhelps mitigate multiple detections of the same object. Our\\nsystem also proposes far fewer bounding boxes, only 98\\nper image compared to about 2000 from Selective Search.\\nFinally, our system combines these individual components\\ninto a single, jointly optimized model.\\nOther Fast Detectors Fast and Faster R-CNN focus on\\nspeeding up the R-CNN framework by sharing computa-\\ntion and using neural networks to propose regions instead\\nof Selective Search [14] [28]. While they offer speed and\\naccuracy improvements over R-CNN, both still fall short of\\nreal-time performance.\\nMany research efforts focus on speeding up the DPM\\npipeline [31] [38] [5]. They speed up HOG computation,\\nuse cascades, and push computation to GPUs. However,\\nonly 30Hz DPM [31] actually runs in real-time.\\nInstead of trying to optimize individual components of\\na large detection pipeline, YOLO throws out the pipeline\\nentirely and is fast by design.\\nDetectors for single classes like faces or people can be\\nhighly optimized since they have to deal with much less\\nvariation [37]. YOLO is a general purpose detector that\\nlearns to detect a variety of objects simultaneously.\\nDeep MultiBox. Unlike R-CNN, Szegedy et al. train a\\nconvolutional neural network to predict regions of interest\\n[8] instead of using Selective Search. MultiBox can also\\nperform single object detection by replacing the confidence\\nprediction with a single class prediction. However, Multi-\\nBox cannot perform general object detection and is still just\\na piece in a larger detection pipeline, requiring further im-\\nage patch classification. Both YOLO and MultiBox use a\\nconvolutional network to predict bounding boxes in an im-\\nage but YOLO is a complete detection system.\\nOverFeat. Sermanet et al. train a convolutional neural\\nnetwork to perform localization and adapt that localizer to\\nperform detection [32]. OverFeat efficiently performs slid-\\ning window detection but it is still a disjoint system. Over-\\nFeat optimizes for localization, not detection performance.\\nLike DPM, the localizer only sees local information when\\nmaking a prediction. OverFeat cannot reason about global\\ncontext and thus requires significant post-processing to pro-\\nduce coherent detections.\\nMultiGrasp. Our work is similar in design to work ongrasp detection by Redmon et al [27]. Our grid approach to\\nbounding box prediction is based on the MultiGrasp system\\nfor regression to grasps. However, grasp detection is a much\\nsimpler task than object detection. MultiGrasp only needs\\nto predict a single graspable region for an image containing\\none object. It doesn’t have to estimate the size, location,\\nor boundaries of the object or predict it’s class, only find a\\nregion suitable for grasping. YOLO predicts both bounding\\nboxes and class probabilities for multiple objects of multi-\\nple classes in an image.\\n4. Experiments\\nFirst we compare YOLO with other real-time detection\\nsystems on P ASCAL VOC 2007. To understand the differ-\\nences between YOLO and R-CNN variants we explore the\\nerrors on VOC 2007 made by YOLO and Fast R-CNN, one\\nof the highest performing versions of R-CNN [14]. Based\\non the different error profiles we show that YOLO can be\\nused to rescore Fast R-CNN detections and reduce the er-\\nrors from background false positives, giving a significant\\nperformance boost. We also present VOC 2012 results and\\ncompare mAP to current state-of-the-art methods. Finally,\\nwe show that YOLO generalizes to new domains better than\\nother detectors on two artwork datasets.\\n4.1. Comparison to Other Real-Time Systems\\nMany research efforts in object detection focus on mak-\\ning standard detection pipelines fast. [5] [38] [31] [14] [17]\\n[28] However, only Sadeghi et al. actually produce a de-\\ntection system that runs in real-time (30 frames per second\\nor better) [31]. We compare YOLO to their GPU imple-\\nmentation of DPM which runs either at 30Hz or 100Hz.\\nWhile the other efforts don’t reach the real-time milestone\\nwe also compare their relative mAP and speed to examine\\nthe accuracy-performance tradeoffs available in object de-\\ntection systems.\\nFast YOLO is the fastest object detection method on\\nPASCAL ; as far as we know, it is the fastest extant object\\ndetector. With 52.7%mAP, it is more than twice as accurate\\nas prior work on real-time detection. YOLO pushes mAP to\\n63.4%while still maintaining real-time performance.\\nWe also train YOLO using VGG-16. This model is more\\naccurate but also significantly slower than YOLO. It is use-\\nful for comparison to other detection systems that rely on\\nVGG-16 but since it is slower than real-time the rest of the\\npaper focuses on our faster models.\\nFastest DPM effectively speeds up DPM without sacri-\\nficing much mAP but it still misses real-time performance\\nby a factor of 2 [38]. It also is limited by DPM’s relatively\\nlow accuracy on detection compared to neural network ap-\\nproaches.\\nR-CNN minus R replaces Selective Search with static\\nbounding box proposals [20]. While it is much faster than', start_char_idx=None, end_char_idx=None, text_template='{metadata_str}\\n\\n{content}', metadata_template='{key}: {value}', metadata_seperator='\\n'),\n", 74 | " Document(id_='58a7cc1d-453e-4829-9971-4e8d45362b87', embedding=None, metadata={'page_label': '6', 'file_name': 'yolo.pdf', 'file_path': 'data\\\\yolo.pdf', 'file_type': 'application/pdf', 'file_size': 5296750, 'creation_date': '2024-01-29', 'last_modified_date': '2024-01-29', 'last_accessed_date': '2024-01-29'}, excluded_embed_metadata_keys=['file_name', 'file_type', 'file_size', 'creation_date', 'last_modified_date', 'last_accessed_date'], excluded_llm_metadata_keys=['file_name', 'file_type', 'file_size', 'creation_date', 'last_modified_date', 'last_accessed_date'], relationships={}, text='Real-Time Detectors Train mAP FPS\\n100Hz DPM [31] 2007 16.0 100\\n30Hz DPM [31] 2007 26.1 30\\nFast YOLO 2007+2012 52.7 155\\nYOLO 2007+2012 63.4 45\\nLess Than Real-Time\\nFastest DPM [38] 2007 30.4 15\\nR-CNN Minus R [20] 2007 53.5 6\\nFast R-CNN [14] 2007+2012 70.0 0.5\\nFaster R-CNN VGG-16[28] 2007+2012 73.2 7\\nFaster R-CNN ZF [28] 2007+2012 62.1 18\\nYOLO VGG-16 2007+2012 66.4 21\\nTable 1: Real-Time Systems on P ASCAL VOC 2007. Compar-\\ning the performance and speed of fast detectors. Fast YOLO is\\nthe fastest detector on record for P ASCAL VOC detection and is\\nstill twice as accurate as any other real-time detector. YOLO is\\n10 mAP more accurate than the fast version while still well above\\nreal-time in speed.\\nR-CNN, it still falls short of real-time and takes a significant\\naccuracy hit from not having good proposals.\\nFast R-CNN speeds up the classification stage of R-CNN\\nbut it still relies on selective search which can take around\\n2 seconds per image to generate bounding box proposals.\\nThus it has high mAP but at 0.5fps it is still far from real-\\ntime.\\nThe recent Faster R-CNN replaces selective search with\\na neural network to propose bounding boxes, similar to\\nSzegedy et al. [8] In our tests, their most accurate model\\nachieves 7 fps while a smaller, less accurate one runs at\\n18 fps. The VGG-16 version of Faster R-CNN is 10 mAP\\nhigher but is also 6 times slower than YOLO. The Zeiler-\\nFergus Faster R-CNN is only 2.5 times slower than YOLO\\nbut is also less accurate.\\n4.2. VOC 2007 Error Analysis\\nTo further examine the differences between YOLO and\\nstate-of-the-art detectors, we look at a detailed breakdown\\nof results on VOC 2007. We compare YOLO to Fast R-\\nCNN since Fast R-CNN is one of the highest performing\\ndetectors on P ASCAL and it’s detections are publicly avail-\\nable.\\nWe use the methodology and tools of Hoiem et al. [19]\\nFor each category at test time we look at the top N predic-\\ntions for that category. Each prediction is either correct or\\nit is classified based on the type of error:\\n•Correct: correct class and IOU >.5\\n•Localization: correct class, .1.1\\nCorrect: 71.6% Correct: 65.5%Loc: 8.6%Sim: 4.3%Other: 1.9%Background: 13.6%\\nLoc: 19.0%Sim: 6.75%Other: 4.0%Background: 4.75%Fast R-CNN YOLOFigure 4: Error Analysis: Fast R-CNN vs. YOLO These\\ncharts show the percentage of localization and background errors\\nin the top N detections for various categories (N = # objects in that\\ncategory).\\n•Other: class is wrong, IOU >.1\\n•Background: IOU <.1for any object\\nFigure 4 shows the breakdown of each error type aver-\\naged across all 20 classes.\\nYOLO struggles to localize objects correctly. Localiza-\\ntion errors account for more of YOLO’s errors than all other\\nsources combined. Fast R-CNN makes much fewer local-\\nization errors but far more background errors. 13.6% of\\nit’s top detections are false positives that don’t contain any\\nobjects. Fast R-CNN is almost 3x more likely to predict\\nbackground detections than YOLO.\\n4.3. Combining Fast R-CNN and YOLO\\nYOLO makes far fewer background mistakes than Fast\\nR-CNN. By using YOLO to eliminate background detec-\\ntions from Fast R-CNN we get a significant boost in perfor-\\nmance. For every bounding box that R-CNN predicts we\\ncheck to see if YOLO predicts a similar box. If it does, we\\ngive that prediction a boost based on the probability pre-\\ndicted by YOLO and the overlap between the two boxes.\\nThe best Fast R-CNN model achieves a mAP of 71.8%\\non the VOC 2007 test set. When combined with YOLO, its\\nmAP Combined Gain\\nFast R-CNN 71.8 - -\\nFast R-CNN (2007 data) 66.9 72.4 .6\\nFast R-CNN (VGG-M) 59.2 72.4 .6\\nFast R-CNN (CaffeNet) 57.1 72.1 .3\\nYOLO 63.4 75.0 3.2\\nTable 2: Model combination experiments on VOC 2007. We\\nexamine the effect of combining various models with the best ver-\\nsion of Fast R-CNN. Other versions of Fast R-CNN provide only\\na small benefit while YOLO provides a significant performance\\nboost.', start_char_idx=None, end_char_idx=None, text_template='{metadata_str}\\n\\n{content}', metadata_template='{key}: {value}', metadata_seperator='\\n'),\n", 75 | " Document(id_='74563dea-3a9c-4d21-b1c9-54c848d25e12', embedding=None, metadata={'page_label': '7', 'file_name': 'yolo.pdf', 'file_path': 'data\\\\yolo.pdf', 'file_type': 'application/pdf', 'file_size': 5296750, 'creation_date': '2024-01-29', 'last_modified_date': '2024-01-29', 'last_accessed_date': '2024-01-29'}, excluded_embed_metadata_keys=['file_name', 'file_type', 'file_size', 'creation_date', 'last_modified_date', 'last_accessed_date'], excluded_llm_metadata_keys=['file_name', 'file_type', 'file_size', 'creation_date', 'last_modified_date', 'last_accessed_date'], relationships={}, text='VOC 2012 test mAP aero bike bird boat bottle bus car cat chair cow table dog horse mbike personplant sheep sofa train tv\\nMR CNN MORE DATA [11] 73.9 85.5 82.9 76.6 57.8 62.7 79.4 77.2 86.6 55.0 79.1 62.2 87.0 83.4 84.7 78.9 45.3 73.4 65.8 80.3 74.0\\nHyperNet VGG 71.4 84.2 78.5 73.6 55.6 53.7 78.7 79.8 87.7 49.6 74.9 52.1 86.0 81.7 83.3 81.8 48.6 73.5 59.4 79.9 65.7\\nHyperNet SP 71.3 84.1 78.3 73.3 55.5 53.6 78.6 79.6 87.5 49.5 74.9 52.1 85.6 81.6 83.2 81.6 48.4 73.2 59.3 79.7 65.6\\nFast R-CNN + YOLO 70.7 83.4 78.5 73.5 55.8 43.4 79.1 73.1 89.4 49.4 75.5 57.0 87.5 80.9 81.0 74.7 41.8 71.5 68.5 82.1 67.2\\nMR CNN SCNN [11] 70.7 85.0 79.6 71.5 55.3 57.7 76.0 73.9 84.6 50.5 74.3 61.7 85.5 79.9 81.7 76.4 41.0 69.0 61.2 77.7 72.1\\nFaster R-CNN [28] 70.4 84.9 79.8 74.3 53.9 49.8 77.5 75.9 88.5 45.6 77.1 55.3 86.9 81.7 80.9 79.6 40.1 72.6 60.9 81.2 61.5\\nDEEP ENS COCO 70.1 84.0 79.4 71.6 51.9 51.1 74.1 72.1 88.6 48.3 73.4 57.8 86.1 80.0 80.7 70.4 46.6 69.6 68.8 75.9 71.4\\nNoC [29] 68.8 82.8 79.0 71.6 52.3 53.7 74.1 69.0 84.9 46.9 74.3 53.1 85.0 81.3 79.5 72.2 38.9 72.4 59.5 76.7 68.1\\nFast R-CNN [14] 68.4 82.3 78.4 70.8 52.3 38.7 77.8 71.6 89.3 44.2 73.0 55.0 87.5 80.5 80.8 72.0 35.1 68.3 65.7 80.4 64.2\\nUMICH FGS STRUCT 66.4 82.9 76.1 64.1 44.6 49.4 70.3 71.2 84.6 42.7 68.6 55.8 82.7 77.1 79.9 68.7 41.4 69.0 60.0 72.0 66.2\\nNUS NIN C2000 [7] 63.8 80.2 73.8 61.9 43.7 43.0 70.3 67.6 80.7 41.9 69.7 51.7 78.2 75.2 76.9 65.1 38.6 68.3 58.0 68.7 63.3\\nBabyLearning [7] 63.2 78.0 74.2 61.3 45.7 42.7 68.2 66.8 80.2 40.6 70.0 49.8 79.0 74.5 77.9 64.0 35.3 67.9 55.7 68.7 62.6\\nNUS NIN 62.4 77.9 73.1 62.6 39.5 43.3 69.1 66.4 78.9 39.1 68.1 50.0 77.2 71.3 76.1 64.7 38.4 66.9 56.2 66.9 62.7\\nR-CNN VGG BB [13] 62.4 79.6 72.7 61.9 41.2 41.9 65.9 66.4 84.6 38.5 67.2 46.7 82.0 74.8 76.0 65.2 35.6 65.4 54.2 67.4 60.3\\nR-CNN VGG [13] 59.2 76.8 70.9 56.6 37.5 36.9 62.9 63.6 81.1 35.7 64.3 43.9 80.4 71.6 74.0 60.0 30.8 63.4 52.0 63.5 58.7\\nYOLO 57.9 77.0 67.2 57.7 38.3 22.7 68.3 55.9 81.4 36.2 60.8 48.5 77.2 72.3 71.3 63.5 28.9 52.2 54.8 73.9 50.8\\nFeature Edit [33] 56.3 74.6 69.1 54.4 39.1 33.1 65.2 62.7 69.7 30.8 56.0 44.6 70.0 64.4 71.1 60.2 33.3 61.3 46.4 61.7 57.8\\nR-CNN BB [13] 53.3 71.8 65.8 52.0 34.1 32.6 59.6 60.0 69.8 27.6 52.0 41.7 69.6 61.3 68.3 57.8 29.6 57.8 40.9 59.3 54.1\\nSDS [16] 50.7 69.7 58.4 48.5 28.3 28.8 61.3 57.5 70.8 24.1 50.7 35.9 64.9 59.1 65.8 57.1 26.0 58.8 38.6 58.9 50.7\\nR-CNN [13] 49.6 68.1 63.8 46.1 29.4 27.9 56.6 57.0 65.9 26.5 48.7 39.5 66.2 57.3 65.4 53.2 26.2 54.5 38.1 50.6 51.6\\nTable 3: PASCAL VOC 2012 Leaderboard. YOLO compared with the full comp4 (outside data allowed) public leaderboard as of\\nNovember 6th, 2015. Mean average precision and per-class average precision are shown for a variety of detection methods. YOLO is the\\nonly real-time detector. Fast R-CNN + YOLO is the forth highest scoring method, with a 2.3% boost over Fast R-CNN.\\nmAP increases by 3.2% to 75.0%. We also tried combining\\nthe top Fast R-CNN model with several other versions of\\nFast R-CNN. Those ensembles produced small increases in\\nmAP between .3 and .6%, see Table 2 for details.\\nThe boost from YOLO is not simply a byproduct of\\nmodel ensembling since there is little benefit from combin-\\ning different versions of Fast R-CNN. Rather, it is precisely\\nbecause YOLO makes different kinds of mistakes at test\\ntime that it is so effective at boosting Fast R-CNN’s per-\\nformance.\\nUnfortunately, this combination doesn’t benefit from the\\nspeed of YOLO since we run each model seperately and\\nthen combine the results. However, since YOLO is so fast\\nit doesn’t add any significant computational time compared\\nto Fast R-CNN.\\n4.4. VOC 2012 Results\\nOn the VOC 2012 test set, YOLO scores 57.9% mAP.\\nThis is lower than the current state of the art, closer to\\nthe original R-CNN using VGG-16, see Table 3. Our sys-\\ntem struggles with small objects compared to its closest\\ncompetitors. On categories like bottle ,sheep , and\\ntv/monitor YOLO scores 8-10% lower than R-CNN or\\nFeature Edit. However, on other categories like cat and\\ntrain YOLO achieves higher performance.\\nOur combined Fast R-CNN + YOLO model is one of the\\nhighest performing detection methods. Fast R-CNN gets\\na 2.3% improvement from the combination with YOLO,\\nboosting it 5 spots up on the public leaderboard.\\n4.5. Generalizability: Person Detection in Artwork\\nAcademic datasets for object detection draw the training\\nand testing data from the same distribution. In real-world\\napplications it is hard to predict all possible use cases andthe test data can diverge from what the system has seen be-\\nfore [3]. We compare YOLO to other detection systems on\\nthe Picasso Dataset [12] and the People-Art Dataset [3], two\\ndatasets for testing person detection on artwork.\\nFigure 5 shows comparative performance between\\nYOLO and other detection methods. For reference, we give\\nVOC 2007 detection AP on person where all models are\\ntrained only on VOC 2007 data. On Picasso models are\\ntrained on VOC 2012 while on People-Art they are trained\\non VOC 2010.\\nR-CNN has high AP on VOC 2007. However, R-CNN\\ndrops off considerably when applied to artwork. R-CNN\\nuses Selective Search for bounding box proposals which is\\ntuned for natural images. The classifier step in R-CNN only\\nsees small regions and needs good proposals.\\nDPM maintains its AP well when applied to artwork.\\nPrior work theorizes that DPM performs well because it has\\nstrong spatial models of the shape and layout of objects.\\nThough DPM doesn’t degrade as much as R-CNN, it starts\\nfrom a lower AP.\\nYOLO has good performance on VOC 2007 and its AP\\ndegrades less than other methods when applied to artwork.\\nLike DPM, YOLO models the size and shape of objects,\\nas well as relationships between objects and where objects\\ncommonly appear. Artwork and natural images are very\\ndifferent on a pixel level but they are similar in terms of\\nthe size and shape of objects, thus YOLO can still predict\\ngood bounding boxes and detections.\\n5. Real-Time Detection In The Wild\\nYOLO is a fast, accurate object detector, making it ideal\\nfor computer vision applications. We connect YOLO to a\\nwebcam and verify that it maintains real-time performance,', start_char_idx=None, end_char_idx=None, text_template='{metadata_str}\\n\\n{content}', metadata_template='{key}: {value}', metadata_seperator='\\n'),\n", 76 | " Document(id_='26012e3c-5d14-471a-9334-bd5b4e75b88f', embedding=None, metadata={'page_label': '8', 'file_name': 'yolo.pdf', 'file_path': 'data\\\\yolo.pdf', 'file_type': 'application/pdf', 'file_size': 5296750, 'creation_date': '2024-01-29', 'last_modified_date': '2024-01-29', 'last_accessed_date': '2024-01-29'}, excluded_embed_metadata_keys=['file_name', 'file_type', 'file_size', 'creation_date', 'last_modified_date', 'last_accessed_date'], excluded_llm_metadata_keys=['file_name', 'file_type', 'file_size', 'creation_date', 'last_modified_date', 'last_accessed_date'], relationships={}, text='Poselets\\nRCNN\\nD&THumans\\nDPMYOLO\\n(a)Picasso Dataset precision-recall curves.VOC 2007 Picasso People-Art\\nAP AP BestF1 AP\\nYOLO 59.2 53.3 0.590 45\\nR-CNN 54.2 10.4 0.226 26\\nDPM 43.2 37.8 0.458 32\\nPoselets [2] 36.5 17.8 0.271\\nD&T [4] - 1.9 0.051\\n(b)Quantitative results on the VOC 2007, Picasso, and People-Art Datasets.\\nThe Picasso Dataset evaluates on both AP and best F1score.\\nFigure 5: Generalization results on Picasso and People-Art datasets.\\nFigure 6: Qualitative Results. YOLO running on sample artwork and natural images from the internet. It is mostly accurate although it\\ndoes think one person is an airplane.\\nincluding the time to fetch images from the camera and dis-\\nplay the detections.\\nThe resulting system is interactive and engaging. While\\nYOLO processes images individually, when attached to a\\nwebcam it functions like a tracking system, detecting ob-\\njects as they move around and change in appearance. A\\ndemo of the system and the source code can be found on\\nour project website: http://pjreddie.com/yolo/ .\\n6. Conclusion\\nWe introduce YOLO, a unified model for object detec-\\ntion. Our model is simple to construct and can be traineddirectly on full images. Unlike classifier-based approaches,\\nYOLO is trained on a loss function that directly corresponds\\nto detection performance and the entire model is trained\\njointly.\\nFast YOLO is the fastest general-purpose object detec-\\ntor in the literature and YOLO pushes the state-of-the-art in\\nreal-time object detection. YOLO also generalizes well to\\nnew domains making it ideal for applications that rely on\\nfast, robust object detection.\\nAcknowledgements: This work is partially supported by\\nONR N00014-13-1-0720, NSF IIS-1338054, and The Allen\\nDistinguished Investigator Award.', start_char_idx=None, end_char_idx=None, text_template='{metadata_str}\\n\\n{content}', metadata_template='{key}: {value}', metadata_seperator='\\n'),\n", 77 | " Document(id_='fbee253a-3a57-4271-809c-b790eafc81fe', embedding=None, metadata={'page_label': '9', 'file_name': 'yolo.pdf', 'file_path': 'data\\\\yolo.pdf', 'file_type': 'application/pdf', 'file_size': 5296750, 'creation_date': '2024-01-29', 'last_modified_date': '2024-01-29', 'last_accessed_date': '2024-01-29'}, excluded_embed_metadata_keys=['file_name', 'file_type', 'file_size', 'creation_date', 'last_modified_date', 'last_accessed_date'], excluded_llm_metadata_keys=['file_name', 'file_type', 'file_size', 'creation_date', 'last_modified_date', 'last_accessed_date'], relationships={}, text='References\\n[1] M. B. Blaschko and C. H. Lampert. Learning to localize ob-\\njects with structured output regression. In Computer Vision–\\nECCV 2008 , pages 2–15. Springer, 2008. 4\\n[2] L. Bourdev and J. Malik. Poselets: Body part detectors\\ntrained using 3d human pose annotations. In International\\nConference on Computer Vision (ICCV) , 2009. 8\\n[3] H. Cai, Q. Wu, T. Corradi, and P. Hall. The cross-\\ndepiction problem: Computer vision algorithms for recog-\\nnising objects in artwork and in photographs. arXiv preprint\\narXiv:1505.00110 , 2015. 7\\n[4] N. Dalal and B. Triggs. Histograms of oriented gradients for\\nhuman detection. In Computer Vision and Pattern Recogni-\\ntion, 2005. CVPR 2005. IEEE Computer Society Conference\\non, volume 1, pages 886–893. IEEE, 2005. 4, 8\\n[5] T. Dean, M. Ruzon, M. Segal, J. Shlens, S. Vijaya-\\nnarasimhan, J. Yagnik, et al. Fast, accurate detection of\\n100,000 object classes on a single machine. In Computer\\nVision and Pattern Recognition (CVPR), 2013 IEEE Confer-\\nence on , pages 1814–1821. IEEE, 2013. 5\\n[6] J. Donahue, Y . Jia, O. Vinyals, J. Hoffman, N. Zhang,\\nE. Tzeng, and T. Darrell. Decaf: A deep convolutional acti-\\nvation feature for generic visual recognition. arXiv preprint\\narXiv:1310.1531 , 2013. 4\\n[7] J. Dong, Q. Chen, S. Yan, and A. Yuille. Towards unified\\nobject detection and semantic segmentation. In Computer\\nVision–ECCV 2014 , pages 299–314. Springer, 2014. 7\\n[8] D. Erhan, C. Szegedy, A. Toshev, and D. Anguelov. Scalable\\nobject detection using deep neural networks. In Computer\\nVision and Pattern Recognition (CVPR), 2014 IEEE Confer-\\nence on , pages 2155–2162. IEEE, 2014. 5, 6\\n[9] M. Everingham, S. M. A. Eslami, L. Van Gool, C. K. I.\\nWilliams, J. Winn, and A. Zisserman. The pascal visual ob-\\nject classes challenge: A retrospective. International Journal\\nof Computer Vision , 111(1):98–136, Jan. 2015. 2\\n[10] P. F. Felzenszwalb, R. B. Girshick, D. McAllester, and D. Ra-\\nmanan. Object detection with discriminatively trained part\\nbased models. IEEE Transactions on Pattern Analysis and\\nMachine Intelligence , 32(9):1627–1645, 2010. 1, 4\\n[11] S. Gidaris and N. Komodakis. Object detection via a multi-\\nregion & semantic segmentation-aware CNN model. CoRR ,\\nabs/1505.01749, 2015. 7\\n[12] S. Ginosar, D. Haas, T. Brown, and J. Malik. Detecting peo-\\nple in cubist art. In Computer Vision-ECCV 2014 Workshops ,\\npages 101–116. Springer, 2014. 7\\n[13] R. Girshick, J. Donahue, T. Darrell, and J. Malik. Rich fea-\\nture hierarchies for accurate object detection and semantic\\nsegmentation. In Computer Vision and Pattern Recognition\\n(CVPR), 2014 IEEE Conference on , pages 580–587. IEEE,\\n2014. 1, 4, 7\\n[14] R. B. Girshick. Fast R-CNN. CoRR , abs/1504.08083, 2015.\\n2, 5, 6, 7\\n[15] S. Gould, T. Gao, and D. Koller. Region-based segmenta-\\ntion and object detection. In Advances in neural information\\nprocessing systems , pages 655–663, 2009. 4[16] B. Hariharan, P. Arbel ´aez, R. Girshick, and J. Malik. Simul-\\ntaneous detection and segmentation. In Computer Vision–\\nECCV 2014 , pages 297–312. Springer, 2014. 7\\n[17] K. He, X. Zhang, S. Ren, and J. Sun. Spatial pyramid pooling\\nin deep convolutional networks for visual recognition. arXiv\\npreprint arXiv:1406.4729 , 2014. 5\\n[18] G. E. Hinton, N. Srivastava, A. Krizhevsky, I. Sutskever, and\\nR. R. Salakhutdinov. Improving neural networks by pre-\\nventing co-adaptation of feature detectors. arXiv preprint\\narXiv:1207.0580 , 2012. 4\\n[19] D. Hoiem, Y . Chodpathumwan, and Q. Dai. Diagnosing error\\nin object detectors. In Computer Vision–ECCV 2012 , pages\\n340–353. Springer, 2012. 6\\n[20] K. Lenc and A. Vedaldi. R-cnn minus r. arXiv preprint\\narXiv:1506.06981 , 2015. 5, 6\\n[21] R. Lienhart and J. Maydt. An extended set of haar-like fea-\\ntures for rapid object detection. In Image Processing. 2002.\\nProceedings. 2002 International Conference on , volume 1,\\npages I–900. IEEE, 2002. 4\\n[22] M. Lin, Q. Chen, and S. Yan. Network in network. CoRR ,\\nabs/1312.4400, 2013. 2\\n[23] D. G. Lowe. Object recognition from local scale-invariant\\nfeatures. In Computer vision, 1999. The proceedings of the\\nseventh IEEE international conference on , volume 2, pages\\n1150–1157. Ieee, 1999. 4\\n[24] D. Mishkin. Models accuracy on imagenet 2012\\nval. https://github.com/BVLC/caffe/wiki/\\nModels-accuracy-on-ImageNet-2012-val . Ac-\\ncessed: 2015-10-2. 3\\n[25] C. P. Papageorgiou, M. Oren, and T. Poggio. A general\\nframework for object detection. In Computer vision, 1998.\\nsixth international conference on , pages 555–562. IEEE,\\n1998. 4\\n[26] J. Redmon. Darknet: Open source neural networks in c.\\nhttp://pjreddie.com/darknet/ , 2013–2016. 3\\n[27] J. Redmon and A. Angelova. Real-time grasp detection using\\nconvolutional neural networks. CoRR , abs/1412.3128, 2014.\\n5\\n[28] S. Ren, K. He, R. Girshick, and J. Sun. Faster r-cnn: To-\\nwards real-time object detection with region proposal net-\\nworks. arXiv preprint arXiv:1506.01497 , 2015. 5, 6, 7\\n[29] S. Ren, K. He, R. B. Girshick, X. Zhang, and J. Sun. Object\\ndetection networks on convolutional feature maps. CoRR ,\\nabs/1504.06066, 2015. 3, 7\\n[30] O. Russakovsky, J. Deng, H. Su, J. Krause, S. Satheesh,\\nS. Ma, Z. Huang, A. Karpathy, A. Khosla, M. Bernstein,\\nA. C. Berg, and L. Fei-Fei. ImageNet Large Scale Visual\\nRecognition Challenge. International Journal of Computer\\nVision (IJCV) , 2015. 3\\n[31] M. A. Sadeghi and D. Forsyth. 30hz object detection with\\ndpm v5. In Computer Vision–ECCV 2014 , pages 65–79.\\nSpringer, 2014. 5, 6\\n[32] P. Sermanet, D. Eigen, X. Zhang, M. Mathieu, R. Fergus,\\nand Y . LeCun. Overfeat: Integrated recognition, localiza-\\ntion and detection using convolutional networks. CoRR ,\\nabs/1312.6229, 2013. 4, 5', start_char_idx=None, end_char_idx=None, text_template='{metadata_str}\\n\\n{content}', metadata_template='{key}: {value}', metadata_seperator='\\n'),\n", 78 | " Document(id_='20a60427-9989-43fa-86c2-3ec233380e77', embedding=None, metadata={'page_label': '10', 'file_name': 'yolo.pdf', 'file_path': 'data\\\\yolo.pdf', 'file_type': 'application/pdf', 'file_size': 5296750, 'creation_date': '2024-01-29', 'last_modified_date': '2024-01-29', 'last_accessed_date': '2024-01-29'}, excluded_embed_metadata_keys=['file_name', 'file_type', 'file_size', 'creation_date', 'last_modified_date', 'last_accessed_date'], excluded_llm_metadata_keys=['file_name', 'file_type', 'file_size', 'creation_date', 'last_modified_date', 'last_accessed_date'], relationships={}, text='[33] Z. Shen and X. Xue. Do more dropouts in pool5 feature maps\\nfor better object detection. arXiv preprint arXiv:1409.6911 ,\\n2014. 7\\n[34] C. Szegedy, W. Liu, Y . Jia, P. Sermanet, S. Reed,\\nD. Anguelov, D. Erhan, V . Vanhoucke, and A. Rabinovich.\\nGoing deeper with convolutions. CoRR , abs/1409.4842,\\n2014. 2\\n[35] J. R. Uijlings, K. E. van de Sande, T. Gevers, and A. W.\\nSmeulders. Selective search for object recognition. Inter-\\nnational journal of computer vision , 104(2):154–171, 2013.\\n4\\n[36] P. Viola and M. Jones. Robust real-time object detection.\\nInternational Journal of Computer Vision , 4:34–47, 2001. 4\\n[37] P. Viola and M. J. Jones. Robust real-time face detection.\\nInternational journal of computer vision , 57(2):137–154,\\n2004. 5\\n[38] J. Yan, Z. Lei, L. Wen, and S. Z. Li. The fastest deformable\\npart model for object detection. In Computer Vision and Pat-\\ntern Recognition (CVPR), 2014 IEEE Conference on , pages\\n2497–2504. IEEE, 2014. 5, 6\\n[39] C. L. Zitnick and P. Doll ´ar. Edge boxes: Locating object pro-\\nposals from edges. In Computer Vision–ECCV 2014 , pages\\n391–405. Springer, 2014. 4', start_char_idx=None, end_char_idx=None, text_template='{metadata_str}\\n\\n{content}', metadata_template='{key}: {value}', metadata_seperator='\\n')]" 79 | ] 80 | }, 81 | "execution_count": 4, 82 | "metadata": {}, 83 | "output_type": "execute_result" 84 | } 85 | ], 86 | "source": [ 87 | "documents" 88 | ] 89 | }, 90 | { 91 | "cell_type": "code", 92 | "execution_count": 5, 93 | "metadata": {}, 94 | "outputs": [ 95 | { 96 | "name": "stderr", 97 | "output_type": "stream", 98 | "text": [ 99 | "e:\\New Recordings\\Langchain Videos\\LLAmindex\\Projects\\Llama_index\\venv\\lib\\site-packages\\tqdm\\auto.py:21: TqdmWarning: IProgress not found. Please update jupyter and ipywidgets. See https://ipywidgets.readthedocs.io/en/stable/user_install.html\n", 100 | " from .autonotebook import tqdm as notebook_tqdm\n", 101 | "Parsing nodes: 100%|██████████| 25/25 [00:00<00:00, 247.44it/s]\n", 102 | "Generating embeddings: 100%|██████████| 36/36 [00:03<00:00, 11.11it/s]\n" 103 | ] 104 | } 105 | ], 106 | "source": [ 107 | "index=VectorStoreIndex.from_documents(documents,show_progress=True)" 108 | ] 109 | }, 110 | { 111 | "cell_type": "code", 112 | "execution_count": 6, 113 | "metadata": {}, 114 | "outputs": [ 115 | { 116 | "data": { 117 | "text/plain": [ 118 | "" 119 | ] 120 | }, 121 | "execution_count": 6, 122 | "metadata": {}, 123 | "output_type": "execute_result" 124 | } 125 | ], 126 | "source": [ 127 | "index" 128 | ] 129 | }, 130 | { 131 | "cell_type": "code", 132 | "execution_count": 7, 133 | "metadata": {}, 134 | "outputs": [], 135 | "source": [ 136 | "query_engine=index.as_query_engine()" 137 | ] 138 | }, 139 | { 140 | "cell_type": "code", 141 | "execution_count": 22, 142 | "metadata": {}, 143 | "outputs": [], 144 | "source": [ 145 | "from llama_index.retrievers import VectorIndexRetriever\n", 146 | "from llama_index.query_engine import RetrieverQueryEngine\n", 147 | "from llama_index.indices.postprocessor import SimilarityPostprocessor\n", 148 | "\n", 149 | "retriever=VectorIndexRetriever(index=index,similarity_top_k=4)\n", 150 | "postprocessor=SimilarityPostprocessor(similarity_cutoff=0.80)\n", 151 | "\n", 152 | "query_engine=RetrieverQueryEngine(retriever=retriever,\n", 153 | " node_postprocessors=[postprocessor])\n" 154 | ] 155 | }, 156 | { 157 | "cell_type": "code", 158 | "execution_count": 23, 159 | "metadata": {}, 160 | "outputs": [], 161 | "source": [ 162 | "response=query_engine.query(\"What is attention is all yopu need?\")" 163 | ] 164 | }, 165 | { 166 | "cell_type": "code", 167 | "execution_count": 24, 168 | "metadata": {}, 169 | "outputs": [ 170 | { 171 | "name": "stdout", 172 | "output_type": "stream", 173 | "text": [ 174 | "Final Response: The paper \"Attention Is All You Need\" proposes a new\n", 175 | "network architecture called the Transformer. This architecture is\n", 176 | "based solely on attention mechanisms and does not use recurrent or\n", 177 | "convolutional neural networks. The paper demonstrates that the\n", 178 | "Transformer models outperform existing models in terms of quality,\n", 179 | "parallelizability, and training time. The Transformer achieves state-\n", 180 | "of-the-art results in machine translation tasks and generalizes well\n", 181 | "to other tasks such as English constituency parsing.\n", 182 | "______________________________________________________________________\n", 183 | "Source Node 1/1\n", 184 | "Node ID: be144ab8-cb0a-44fa-af69-3dbfe555e41a\n", 185 | "Similarity: 0.8107415810551661\n", 186 | "Text: Provided proper attribution is provided, Google hereby grants\n", 187 | "permission to reproduce the tables and figures in this paper solely\n", 188 | "for use in journalistic or scholarly works. Attention Is All You Need\n", 189 | "Ashish Vaswani∗ Google Brain avaswani@google.comNoam Shazeer∗ Google\n", 190 | "Brain noam@google.comNiki Parmar∗ Google Research\n", 191 | "nikip@google.comJakob Uszkor...\n", 192 | "The paper \"Attention Is All You Need\" proposes a new network architecture called the Transformer. This architecture is based solely on attention mechanisms and does not use recurrent or convolutional neural networks. The paper demonstrates that the Transformer models outperform existing models in terms of quality, parallelizability, and training time. The Transformer achieves state-of-the-art results in machine translation tasks and generalizes well to other tasks such as English constituency parsing.\n" 193 | ] 194 | } 195 | ], 196 | "source": [ 197 | "from llama_index.response.pprint_utils import pprint_response\n", 198 | "pprint_response(response,show_source=True)\n", 199 | "print(response)" 200 | ] 201 | }, 202 | { 203 | "cell_type": "code", 204 | "execution_count": 25, 205 | "metadata": {}, 206 | "outputs": [ 207 | { 208 | "name": "stdout", 209 | "output_type": "stream", 210 | "text": [ 211 | "Transformers are a model architecture that rely entirely on an attention mechanism to draw global dependencies between input and output. They eschew recurrence and do not use sequence-aligned RNNs or convolution. Transformers allow for significantly more parallelization and have been shown to achieve state-of-the-art results in tasks such as translation. They can be trained faster than architectures based on recurrent or convolutional layers.\n" 212 | ] 213 | } 214 | ], 215 | "source": [ 216 | "import os.path\n", 217 | "from llama_index import (\n", 218 | " VectorStoreIndex,\n", 219 | " SimpleDirectoryReader,\n", 220 | " StorageContext,\n", 221 | " load_index_from_storage,\n", 222 | ")\n", 223 | "\n", 224 | "# check if storage already exists\n", 225 | "PERSIST_DIR = \"./storage\"\n", 226 | "if not os.path.exists(PERSIST_DIR):\n", 227 | " # load the documents and create the index\n", 228 | " documents = SimpleDirectoryReader(\"data\").load_data()\n", 229 | " index = VectorStoreIndex.from_documents(documents)\n", 230 | " # store it for later\n", 231 | " index.storage_context.persist(persist_dir=PERSIST_DIR)\n", 232 | "else:\n", 233 | " # load the existing index\n", 234 | " storage_context = StorageContext.from_defaults(persist_dir=PERSIST_DIR)\n", 235 | " index = load_index_from_storage(storage_context)\n", 236 | "\n", 237 | "# either way we can now query the index\n", 238 | "query_engine = index.as_query_engine()\n", 239 | "response = query_engine.query(\"What are transformers?\")\n", 240 | "print(response)" 241 | ] 242 | }, 243 | { 244 | "cell_type": "code", 245 | "execution_count": null, 246 | "metadata": {}, 247 | "outputs": [], 248 | "source": [] 249 | } 250 | ], 251 | "metadata": { 252 | "kernelspec": { 253 | "display_name": "Python 3", 254 | "language": "python", 255 | "name": "python3" 256 | }, 257 | "language_info": { 258 | "codemirror_mode": { 259 | "name": "ipython", 260 | "version": 3 261 | }, 262 | "file_extension": ".py", 263 | "mimetype": "text/x-python", 264 | "name": "python", 265 | "nbconvert_exporter": "python", 266 | "pygments_lexer": "ipython3", 267 | "version": "3.10.0" 268 | } 269 | }, 270 | "nbformat": 4, 271 | "nbformat_minor": 2 272 | } 273 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 3, 29 June 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | Preamble 9 | 10 | The GNU General Public License is a free, copyleft license for 11 | software and other kinds of works. 12 | 13 | The licenses for most software and other practical works are designed 14 | to take away your freedom to share and change the works. By contrast, 15 | the GNU General Public License is intended to guarantee your freedom to 16 | share and change all versions of a program--to make sure it remains free 17 | software for all its users. We, the Free Software Foundation, use the 18 | GNU General Public License for most of our software; it applies also to 19 | any other work released this way by its authors. You can apply it to 20 | your programs, too. 21 | 22 | When we speak of free software, we are referring to freedom, not 23 | price. Our General Public Licenses are designed to make sure that you 24 | have the freedom to distribute copies of free software (and charge for 25 | them if you wish), that you receive source code or can get it if you 26 | want it, that you can change the software or use pieces of it in new 27 | free programs, and that you know you can do these things. 28 | 29 | To protect your rights, we need to prevent others from denying you 30 | these rights or asking you to surrender the rights. Therefore, you have 31 | certain responsibilities if you distribute copies of the software, or if 32 | you modify it: responsibilities to respect the freedom of others. 33 | 34 | For example, if you distribute copies of such a program, whether 35 | gratis or for a fee, you must pass on to the recipients the same 36 | freedoms that you received. You must make sure that they, too, receive 37 | or can get the source code. And you must show them these terms so they 38 | know their rights. 39 | 40 | Developers that use the GNU GPL protect your rights with two steps: 41 | (1) assert copyright on the software, and (2) offer you this License 42 | giving you legal permission to copy, distribute and/or modify it. 43 | 44 | For the developers' and authors' protection, the GPL clearly explains 45 | that there is no warranty for this free software. For both users' and 46 | authors' sake, the GPL requires that modified versions be marked as 47 | changed, so that their problems will not be attributed erroneously to 48 | authors of previous versions. 49 | 50 | Some devices are designed to deny users access to install or run 51 | modified versions of the software inside them, although the manufacturer 52 | can do so. This is fundamentally incompatible with the aim of 53 | protecting users' freedom to change the software. The systematic 54 | pattern of such abuse occurs in the area of products for individuals to 55 | use, which is precisely where it is most unacceptable. Therefore, we 56 | have designed this version of the GPL to prohibit the practice for those 57 | products. If such problems arise substantially in other domains, we 58 | stand ready to extend this provision to those domains in future versions 59 | of the GPL, as needed to protect the freedom of users. 60 | 61 | Finally, every program is threatened constantly by software patents. 62 | States should not allow patents to restrict development and use of 63 | software on general-purpose computers, but in those that do, we wish to 64 | avoid the special danger that patents applied to a free program could 65 | make it effectively proprietary. To prevent this, the GPL assures that 66 | patents cannot be used to render the program non-free. 67 | 68 | The precise terms and conditions for copying, distribution and 69 | modification follow. 70 | 71 | TERMS AND CONDITIONS 72 | 73 | 0. Definitions. 74 | 75 | "This License" refers to version 3 of the GNU General Public License. 76 | 77 | "Copyright" also means copyright-like laws that apply to other kinds of 78 | works, such as semiconductor masks. 79 | 80 | "The Program" refers to any copyrightable work licensed under this 81 | License. Each licensee is addressed as "you". "Licensees" and 82 | "recipients" may be individuals or organizations. 83 | 84 | To "modify" a work means to copy from or adapt all or part of the work 85 | in a fashion requiring copyright permission, other than the making of an 86 | exact copy. The resulting work is called a "modified version" of the 87 | earlier work or a work "based on" the earlier work. 88 | 89 | A "covered work" means either the unmodified Program or a work based 90 | on the Program. 91 | 92 | To "propagate" a work means to do anything with it that, without 93 | permission, would make you directly or secondarily liable for 94 | infringement under applicable copyright law, except executing it on a 95 | computer or modifying a private copy. Propagation includes copying, 96 | distribution (with or without modification), making available to the 97 | public, and in some countries other activities as well. 98 | 99 | To "convey" a work means any kind of propagation that enables other 100 | parties to make or receive copies. Mere interaction with a user through 101 | a computer network, with no transfer of a copy, is not conveying. 102 | 103 | An interactive user interface displays "Appropriate Legal Notices" 104 | to the extent that it includes a convenient and prominently visible 105 | feature that (1) displays an appropriate copyright notice, and (2) 106 | tells the user that there is no warranty for the work (except to the 107 | extent that warranties are provided), that licensees may convey the 108 | work under this License, and how to view a copy of this License. If 109 | the interface presents a list of user commands or options, such as a 110 | menu, a prominent item in the list meets this criterion. 111 | 112 | 1. Source Code. 113 | 114 | The "source code" for a work means the preferred form of the work 115 | for making modifications to it. "Object code" means any non-source 116 | form of a work. 117 | 118 | A "Standard Interface" means an interface that either is an official 119 | standard defined by a recognized standards body, or, in the case of 120 | interfaces specified for a particular programming language, one that 121 | is widely used among developers working in that language. 122 | 123 | The "System Libraries" of an executable work include anything, other 124 | than the work as a whole, that (a) is included in the normal form of 125 | packaging a Major Component, but which is not part of that Major 126 | Component, and (b) serves only to enable use of the work with that 127 | Major Component, or to implement a Standard Interface for which an 128 | implementation is available to the public in source code form. A 129 | "Major Component", in this context, means a major essential component 130 | (kernel, window system, and so on) of the specific operating system 131 | (if any) on which the executable work runs, or a compiler used to 132 | produce the work, or an object code interpreter used to run it. 133 | 134 | The "Corresponding Source" for a work in object code form means all 135 | the source code needed to generate, install, and (for an executable 136 | work) run the object code and to modify the work, including scripts to 137 | control those activities. However, it does not include the work's 138 | System Libraries, or general-purpose tools or generally available free 139 | programs which are used unmodified in performing those activities but 140 | which are not part of the work. For example, Corresponding Source 141 | includes interface definition files associated with source files for 142 | the work, and the source code for shared libraries and dynamically 143 | linked subprograms that the work is specifically designed to require, 144 | such as by intimate data communication or control flow between those 145 | subprograms and other parts of the work. 146 | 147 | The Corresponding Source need not include anything that users 148 | can regenerate automatically from other parts of the Corresponding 149 | Source. 150 | 151 | The Corresponding Source for a work in source code form is that 152 | same work. 153 | 154 | 2. Basic Permissions. 155 | 156 | All rights granted under this License are granted for the term of 157 | copyright on the Program, and are irrevocable provided the stated 158 | conditions are met. This License explicitly affirms your unlimited 159 | permission to run the unmodified Program. The output from running a 160 | covered work is covered by this License only if the output, given its 161 | content, constitutes a covered work. This License acknowledges your 162 | rights of fair use or other equivalent, as provided by copyright law. 163 | 164 | You may make, run and propagate covered works that you do not 165 | convey, without conditions so long as your license otherwise remains 166 | in force. You may convey covered works to others for the sole purpose 167 | of having them make modifications exclusively for you, or provide you 168 | with facilities for running those works, provided that you comply with 169 | the terms of this License in conveying all material for which you do 170 | not control copyright. Those thus making or running the covered works 171 | for you must do so exclusively on your behalf, under your direction 172 | and control, on terms that prohibit them from making any copies of 173 | your copyrighted material outside their relationship with you. 174 | 175 | Conveying under any other circumstances is permitted solely under 176 | the conditions stated below. Sublicensing is not allowed; section 10 177 | makes it unnecessary. 178 | 179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 180 | 181 | No covered work shall be deemed part of an effective technological 182 | measure under any applicable law fulfilling obligations under article 183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 184 | similar laws prohibiting or restricting circumvention of such 185 | measures. 186 | 187 | When you convey a covered work, you waive any legal power to forbid 188 | circumvention of technological measures to the extent such circumvention 189 | is effected by exercising rights under this License with respect to 190 | the covered work, and you disclaim any intention to limit operation or 191 | modification of the work as a means of enforcing, against the work's 192 | users, your or third parties' legal rights to forbid circumvention of 193 | technological measures. 194 | 195 | 4. Conveying Verbatim Copies. 196 | 197 | You may convey verbatim copies of the Program's source code as you 198 | receive it, in any medium, provided that you conspicuously and 199 | appropriately publish on each copy an appropriate copyright notice; 200 | keep intact all notices stating that this License and any 201 | non-permissive terms added in accord with section 7 apply to the code; 202 | keep intact all notices of the absence of any warranty; and give all 203 | recipients a copy of this License along with the Program. 204 | 205 | You may charge any price or no price for each copy that you convey, 206 | and you may offer support or warranty protection for a fee. 207 | 208 | 5. Conveying Modified Source Versions. 209 | 210 | You may convey a work based on the Program, or the modifications to 211 | produce it from the Program, in the form of source code under the 212 | terms of section 4, provided that you also meet all of these conditions: 213 | 214 | a) The work must carry prominent notices stating that you modified 215 | it, and giving a relevant date. 216 | 217 | b) The work must carry prominent notices stating that it is 218 | released under this License and any conditions added under section 219 | 7. This requirement modifies the requirement in section 4 to 220 | "keep intact all notices". 221 | 222 | c) You must license the entire work, as a whole, under this 223 | License to anyone who comes into possession of a copy. This 224 | License will therefore apply, along with any applicable section 7 225 | additional terms, to the whole of the work, and all its parts, 226 | regardless of how they are packaged. This License gives no 227 | permission to license the work in any other way, but it does not 228 | invalidate such permission if you have separately received it. 229 | 230 | d) If the work has interactive user interfaces, each must display 231 | Appropriate Legal Notices; however, if the Program has interactive 232 | interfaces that do not display Appropriate Legal Notices, your 233 | work need not make them do so. 234 | 235 | A compilation of a covered work with other separate and independent 236 | works, which are not by their nature extensions of the covered work, 237 | and which are not combined with it such as to form a larger program, 238 | in or on a volume of a storage or distribution medium, is called an 239 | "aggregate" if the compilation and its resulting copyright are not 240 | used to limit the access or legal rights of the compilation's users 241 | beyond what the individual works permit. Inclusion of a covered work 242 | in an aggregate does not cause this License to apply to the other 243 | parts of the aggregate. 244 | 245 | 6. Conveying Non-Source Forms. 246 | 247 | You may convey a covered work in object code form under the terms 248 | of sections 4 and 5, provided that you also convey the 249 | machine-readable Corresponding Source under the terms of this License, 250 | in one of these ways: 251 | 252 | a) Convey the object code in, or embodied in, a physical product 253 | (including a physical distribution medium), accompanied by the 254 | Corresponding Source fixed on a durable physical medium 255 | customarily used for software interchange. 256 | 257 | b) Convey the object code in, or embodied in, a physical product 258 | (including a physical distribution medium), accompanied by a 259 | written offer, valid for at least three years and valid for as 260 | long as you offer spare parts or customer support for that product 261 | model, to give anyone who possesses the object code either (1) a 262 | copy of the Corresponding Source for all the software in the 263 | product that is covered by this License, on a durable physical 264 | medium customarily used for software interchange, for a price no 265 | more than your reasonable cost of physically performing this 266 | conveying of source, or (2) access to copy the 267 | Corresponding Source from a network server at no charge. 268 | 269 | c) Convey individual copies of the object code with a copy of the 270 | written offer to provide the Corresponding Source. This 271 | alternative is allowed only occasionally and noncommercially, and 272 | only if you received the object code with such an offer, in accord 273 | with subsection 6b. 274 | 275 | d) Convey the object code by offering access from a designated 276 | place (gratis or for a charge), and offer equivalent access to the 277 | Corresponding Source in the same way through the same place at no 278 | further charge. You need not require recipients to copy the 279 | Corresponding Source along with the object code. If the place to 280 | copy the object code is a network server, the Corresponding Source 281 | may be on a different server (operated by you or a third party) 282 | that supports equivalent copying facilities, provided you maintain 283 | clear directions next to the object code saying where to find the 284 | Corresponding Source. Regardless of what server hosts the 285 | Corresponding Source, you remain obligated to ensure that it is 286 | available for as long as needed to satisfy these requirements. 287 | 288 | e) Convey the object code using peer-to-peer transmission, provided 289 | you inform other peers where the object code and Corresponding 290 | Source of the work are being offered to the general public at no 291 | charge under subsection 6d. 292 | 293 | A separable portion of the object code, whose source code is excluded 294 | from the Corresponding Source as a System Library, need not be 295 | included in conveying the object code work. 296 | 297 | A "User Product" is either (1) a "consumer product", which means any 298 | tangible personal property which is normally used for personal, family, 299 | or household purposes, or (2) anything designed or sold for incorporation 300 | into a dwelling. In determining whether a product is a consumer product, 301 | doubtful cases shall be resolved in favor of coverage. For a particular 302 | product received by a particular user, "normally used" refers to a 303 | typical or common use of that class of product, regardless of the status 304 | of the particular user or of the way in which the particular user 305 | actually uses, or expects or is expected to use, the product. A product 306 | is a consumer product regardless of whether the product has substantial 307 | commercial, industrial or non-consumer uses, unless such uses represent 308 | the only significant mode of use of the product. 309 | 310 | "Installation Information" for a User Product means any methods, 311 | procedures, authorization keys, or other information required to install 312 | and execute modified versions of a covered work in that User Product from 313 | a modified version of its Corresponding Source. The information must 314 | suffice to ensure that the continued functioning of the modified object 315 | code is in no case prevented or interfered with solely because 316 | modification has been made. 317 | 318 | If you convey an object code work under this section in, or with, or 319 | specifically for use in, a User Product, and the conveying occurs as 320 | part of a transaction in which the right of possession and use of the 321 | User Product is transferred to the recipient in perpetuity or for a 322 | fixed term (regardless of how the transaction is characterized), the 323 | Corresponding Source conveyed under this section must be accompanied 324 | by the Installation Information. But this requirement does not apply 325 | if neither you nor any third party retains the ability to install 326 | modified object code on the User Product (for example, the work has 327 | been installed in ROM). 328 | 329 | The requirement to provide Installation Information does not include a 330 | requirement to continue to provide support service, warranty, or updates 331 | for a work that has been modified or installed by the recipient, or for 332 | the User Product in which it has been modified or installed. Access to a 333 | network may be denied when the modification itself materially and 334 | adversely affects the operation of the network or violates the rules and 335 | protocols for communication across the network. 336 | 337 | Corresponding Source conveyed, and Installation Information provided, 338 | in accord with this section must be in a format that is publicly 339 | documented (and with an implementation available to the public in 340 | source code form), and must require no special password or key for 341 | unpacking, reading or copying. 342 | 343 | 7. Additional Terms. 344 | 345 | "Additional permissions" are terms that supplement the terms of this 346 | License by making exceptions from one or more of its conditions. 347 | Additional permissions that are applicable to the entire Program shall 348 | be treated as though they were included in this License, to the extent 349 | that they are valid under applicable law. If additional permissions 350 | apply only to part of the Program, that part may be used separately 351 | under those permissions, but the entire Program remains governed by 352 | this License without regard to the additional permissions. 353 | 354 | When you convey a copy of a covered work, you may at your option 355 | remove any additional permissions from that copy, or from any part of 356 | it. (Additional permissions may be written to require their own 357 | removal in certain cases when you modify the work.) You may place 358 | additional permissions on material, added by you to a covered work, 359 | for which you have or can give appropriate copyright permission. 360 | 361 | Notwithstanding any other provision of this License, for material you 362 | add to a covered work, you may (if authorized by the copyright holders of 363 | that material) supplement the terms of this License with terms: 364 | 365 | a) Disclaiming warranty or limiting liability differently from the 366 | terms of sections 15 and 16 of this License; or 367 | 368 | b) Requiring preservation of specified reasonable legal notices or 369 | author attributions in that material or in the Appropriate Legal 370 | Notices displayed by works containing it; or 371 | 372 | c) Prohibiting misrepresentation of the origin of that material, or 373 | requiring that modified versions of such material be marked in 374 | reasonable ways as different from the original version; or 375 | 376 | d) Limiting the use for publicity purposes of names of licensors or 377 | authors of the material; or 378 | 379 | e) Declining to grant rights under trademark law for use of some 380 | trade names, trademarks, or service marks; or 381 | 382 | f) Requiring indemnification of licensors and authors of that 383 | material by anyone who conveys the material (or modified versions of 384 | it) with contractual assumptions of liability to the recipient, for 385 | any liability that these contractual assumptions directly impose on 386 | those licensors and authors. 387 | 388 | All other non-permissive additional terms are considered "further 389 | restrictions" within the meaning of section 10. If the Program as you 390 | received it, or any part of it, contains a notice stating that it is 391 | governed by this License along with a term that is a further 392 | restriction, you may remove that term. If a license document contains 393 | a further restriction but permits relicensing or conveying under this 394 | License, you may add to a covered work material governed by the terms 395 | of that license document, provided that the further restriction does 396 | not survive such relicensing or conveying. 397 | 398 | If you add terms to a covered work in accord with this section, you 399 | must place, in the relevant source files, a statement of the 400 | additional terms that apply to those files, or a notice indicating 401 | where to find the applicable terms. 402 | 403 | Additional terms, permissive or non-permissive, may be stated in the 404 | form of a separately written license, or stated as exceptions; 405 | the above requirements apply either way. 406 | 407 | 8. Termination. 408 | 409 | You may not propagate or modify a covered work except as expressly 410 | provided under this License. Any attempt otherwise to propagate or 411 | modify it is void, and will automatically terminate your rights under 412 | this License (including any patent licenses granted under the third 413 | paragraph of section 11). 414 | 415 | However, if you cease all violation of this License, then your 416 | license from a particular copyright holder is reinstated (a) 417 | provisionally, unless and until the copyright holder explicitly and 418 | finally terminates your license, and (b) permanently, if the copyright 419 | holder fails to notify you of the violation by some reasonable means 420 | prior to 60 days after the cessation. 421 | 422 | Moreover, your license from a particular copyright holder is 423 | reinstated permanently if the copyright holder notifies you of the 424 | violation by some reasonable means, this is the first time you have 425 | received notice of violation of this License (for any work) from that 426 | copyright holder, and you cure the violation prior to 30 days after 427 | your receipt of the notice. 428 | 429 | Termination of your rights under this section does not terminate the 430 | licenses of parties who have received copies or rights from you under 431 | this License. If your rights have been terminated and not permanently 432 | reinstated, you do not qualify to receive new licenses for the same 433 | material under section 10. 434 | 435 | 9. Acceptance Not Required for Having Copies. 436 | 437 | You are not required to accept this License in order to receive or 438 | run a copy of the Program. Ancillary propagation of a covered work 439 | occurring solely as a consequence of using peer-to-peer transmission 440 | to receive a copy likewise does not require acceptance. However, 441 | nothing other than this License grants you permission to propagate or 442 | modify any covered work. These actions infringe copyright if you do 443 | not accept this License. Therefore, by modifying or propagating a 444 | covered work, you indicate your acceptance of this License to do so. 445 | 446 | 10. Automatic Licensing of Downstream Recipients. 447 | 448 | Each time you convey a covered work, the recipient automatically 449 | receives a license from the original licensors, to run, modify and 450 | propagate that work, subject to this License. You are not responsible 451 | for enforcing compliance by third parties with this License. 452 | 453 | An "entity transaction" is a transaction transferring control of an 454 | organization, or substantially all assets of one, or subdividing an 455 | organization, or merging organizations. If propagation of a covered 456 | work results from an entity transaction, each party to that 457 | transaction who receives a copy of the work also receives whatever 458 | licenses to the work the party's predecessor in interest had or could 459 | give under the previous paragraph, plus a right to possession of the 460 | Corresponding Source of the work from the predecessor in interest, if 461 | the predecessor has it or can get it with reasonable efforts. 462 | 463 | You may not impose any further restrictions on the exercise of the 464 | rights granted or affirmed under this License. For example, you may 465 | not impose a license fee, royalty, or other charge for exercise of 466 | rights granted under this License, and you may not initiate litigation 467 | (including a cross-claim or counterclaim in a lawsuit) alleging that 468 | any patent claim is infringed by making, using, selling, offering for 469 | sale, or importing the Program or any portion of it. 470 | 471 | 11. Patents. 472 | 473 | A "contributor" is a copyright holder who authorizes use under this 474 | License of the Program or a work on which the Program is based. The 475 | work thus licensed is called the contributor's "contributor version". 476 | 477 | A contributor's "essential patent claims" are all patent claims 478 | owned or controlled by the contributor, whether already acquired or 479 | hereafter acquired, that would be infringed by some manner, permitted 480 | by this License, of making, using, or selling its contributor version, 481 | but do not include claims that would be infringed only as a 482 | consequence of further modification of the contributor version. For 483 | purposes of this definition, "control" includes the right to grant 484 | patent sublicenses in a manner consistent with the requirements of 485 | this License. 486 | 487 | Each contributor grants you a non-exclusive, worldwide, royalty-free 488 | patent license under the contributor's essential patent claims, to 489 | make, use, sell, offer for sale, import and otherwise run, modify and 490 | propagate the contents of its contributor version. 491 | 492 | In the following three paragraphs, a "patent license" is any express 493 | agreement or commitment, however denominated, not to enforce a patent 494 | (such as an express permission to practice a patent or covenant not to 495 | sue for patent infringement). To "grant" such a patent license to a 496 | party means to make such an agreement or commitment not to enforce a 497 | patent against the party. 498 | 499 | If you convey a covered work, knowingly relying on a patent license, 500 | and the Corresponding Source of the work is not available for anyone 501 | to copy, free of charge and under the terms of this License, through a 502 | publicly available network server or other readily accessible means, 503 | then you must either (1) cause the Corresponding Source to be so 504 | available, or (2) arrange to deprive yourself of the benefit of the 505 | patent license for this particular work, or (3) arrange, in a manner 506 | consistent with the requirements of this License, to extend the patent 507 | license to downstream recipients. "Knowingly relying" means you have 508 | actual knowledge that, but for the patent license, your conveying the 509 | covered work in a country, or your recipient's use of the covered work 510 | in a country, would infringe one or more identifiable patents in that 511 | country that you have reason to believe are valid. 512 | 513 | If, pursuant to or in connection with a single transaction or 514 | arrangement, you convey, or propagate by procuring conveyance of, a 515 | covered work, and grant a patent license to some of the parties 516 | receiving the covered work authorizing them to use, propagate, modify 517 | or convey a specific copy of the covered work, then the patent license 518 | you grant is automatically extended to all recipients of the covered 519 | work and works based on it. 520 | 521 | A patent license is "discriminatory" if it does not include within 522 | the scope of its coverage, prohibits the exercise of, or is 523 | conditioned on the non-exercise of one or more of the rights that are 524 | specifically granted under this License. You may not convey a covered 525 | work if you are a party to an arrangement with a third party that is 526 | in the business of distributing software, under which you make payment 527 | to the third party based on the extent of your activity of conveying 528 | the work, and under which the third party grants, to any of the 529 | parties who would receive the covered work from you, a discriminatory 530 | patent license (a) in connection with copies of the covered work 531 | conveyed by you (or copies made from those copies), or (b) primarily 532 | for and in connection with specific products or compilations that 533 | contain the covered work, unless you entered into that arrangement, 534 | or that patent license was granted, prior to 28 March 2007. 535 | 536 | Nothing in this License shall be construed as excluding or limiting 537 | any implied license or other defenses to infringement that may 538 | otherwise be available to you under applicable patent law. 539 | 540 | 12. No Surrender of Others' Freedom. 541 | 542 | If conditions are imposed on you (whether by court order, agreement or 543 | otherwise) that contradict the conditions of this License, they do not 544 | excuse you from the conditions of this License. If you cannot convey a 545 | covered work so as to satisfy simultaneously your obligations under this 546 | License and any other pertinent obligations, then as a consequence you may 547 | not convey it at all. For example, if you agree to terms that obligate you 548 | to collect a royalty for further conveying from those to whom you convey 549 | the Program, the only way you could satisfy both those terms and this 550 | License would be to refrain entirely from conveying the Program. 551 | 552 | 13. Use with the GNU Affero General Public License. 553 | 554 | Notwithstanding any other provision of this License, you have 555 | permission to link or combine any covered work with a work licensed 556 | under version 3 of the GNU Affero General Public License into a single 557 | combined work, and to convey the resulting work. The terms of this 558 | License will continue to apply to the part which is the covered work, 559 | but the special requirements of the GNU Affero General Public License, 560 | section 13, concerning interaction through a network will apply to the 561 | combination as such. 562 | 563 | 14. Revised Versions of this License. 564 | 565 | The Free Software Foundation may publish revised and/or new versions of 566 | the GNU General Public License from time to time. Such new versions will 567 | be similar in spirit to the present version, but may differ in detail to 568 | address new problems or concerns. 569 | 570 | Each version is given a distinguishing version number. If the 571 | Program specifies that a certain numbered version of the GNU General 572 | Public License "or any later version" applies to it, you have the 573 | option of following the terms and conditions either of that numbered 574 | version or of any later version published by the Free Software 575 | Foundation. If the Program does not specify a version number of the 576 | GNU General Public License, you may choose any version ever published 577 | by the Free Software Foundation. 578 | 579 | If the Program specifies that a proxy can decide which future 580 | versions of the GNU General Public License can be used, that proxy's 581 | public statement of acceptance of a version permanently authorizes you 582 | to choose that version for the Program. 583 | 584 | Later license versions may give you additional or different 585 | permissions. However, no additional obligations are imposed on any 586 | author or copyright holder as a result of your choosing to follow a 587 | later version. 588 | 589 | 15. Disclaimer of Warranty. 590 | 591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 599 | 600 | 16. Limitation of Liability. 601 | 602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 610 | SUCH DAMAGES. 611 | 612 | 17. Interpretation of Sections 15 and 16. 613 | 614 | If the disclaimer of warranty and limitation of liability provided 615 | above cannot be given local legal effect according to their terms, 616 | reviewing courts shall apply local law that most closely approximates 617 | an absolute waiver of all civil liability in connection with the 618 | Program, unless a warranty or assumption of liability accompanies a 619 | copy of the Program in return for a fee. 620 | 621 | END OF TERMS AND CONDITIONS 622 | 623 | How to Apply These Terms to Your New Programs 624 | 625 | If you develop a new program, and you want it to be of the greatest 626 | possible use to the public, the best way to achieve this is to make it 627 | free software which everyone can redistribute and change under these terms. 628 | 629 | To do so, attach the following notices to the program. It is safest 630 | to attach them to the start of each source file to most effectively 631 | state the exclusion of warranty; and each file should have at least 632 | the "copyright" line and a pointer to where the full notice is found. 633 | 634 | 635 | Copyright (C) 636 | 637 | This program is free software: you can redistribute it and/or modify 638 | it under the terms of the GNU General Public License as published by 639 | the Free Software Foundation, either version 3 of the License, or 640 | (at your option) any later version. 641 | 642 | This program is distributed in the hope that it will be useful, 643 | but WITHOUT ANY WARRANTY; without even the implied warranty of 644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 645 | GNU General Public License for more details. 646 | 647 | You should have received a copy of the GNU General Public License 648 | along with this program. If not, see . 649 | 650 | Also add information on how to contact you by electronic and paper mail. 651 | 652 | If the program does terminal interaction, make it output a short 653 | notice like this when it starts in an interactive mode: 654 | 655 | Copyright (C) 656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 657 | This is free software, and you are welcome to redistribute it 658 | under certain conditions; type `show c' for details. 659 | 660 | The hypothetical commands `show w' and `show c' should show the appropriate 661 | parts of the General Public License. Of course, your program's commands 662 | might be different; for a GUI interface, you would use an "about box". 663 | 664 | You should also get your employer (if you work as a programmer) or school, 665 | if any, to sign a "copyright disclaimer" for the program, if necessary. 666 | For more information on this, and how to apply and follow the GNU GPL, see 667 | . 668 | 669 | The GNU General Public License does not permit incorporating your program 670 | into proprietary programs. If your program is a subroutine library, you 671 | may consider it more useful to permit linking proprietary applications with 672 | the library. If this is what you want to do, use the GNU Lesser General 673 | Public License instead of this License. But first, please read 674 | . 675 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Llamindex-Projects --------------------------------------------------------------------------------