Spaces:
Running
on
CPU Upgrade
Running
on
CPU Upgrade
File size: 4,949 Bytes
63858e7 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 |
# see also: https://github.com/hjacobs/connexion-example
swagger: '2.0'
info:
title: BERT-viz API
version: "0.0.1"
consumes:
- application/json
produces:
- application/json
basePath: /api
# ===============================================================================
## DEFINE API ##
# ===============================================================================
paths:
/get-model-details:
get:
tags: [All]
operationId: main.get_model_details
summary: Get necessary information about the model, such as number of layers and heads
parameters:
- name: model
description: Short string representing pretrained model, such as 'bert-base-uncased'
in: query
type: string
responses:
200:
description: Returns information about the model
/attend+meta:
get:
tags: [All]
operationId: main.get_attention_and_meta
summary: Get the attention information, BERT Embeddings, and spacy meta info for an input sentence
parameters:
- name: model
description: Which pretrained transformer information is requested from
in: query
type: string
- name: sentence
description: Sentence to analyze
in: query
type: string
- name: layer
description: Layer to get attentions at
in: query
type: number
responses:
200:
description: Returns attentions, embeddings, and metadata
/update-mask:
post:
tags: [All]
operationId: main.update_masked_attention
summary: Get the masked attention information of tokens given indices to mask
parameters:
- name: payload
description: Main contents
in: body
schema:
$ref: '#/definitions/maskPayload'
responses:
200:
description: Update BERT's masked behavior for passed tokens
/k-nearest-embeddings:
get:
tags: [All]
operationId: main.nearest_embedding_search
summary: Search for the nearest embeddings to a token sent from the frontend by layer
parameters:
- name: model
description: Which model to get information from
in: query
type: string
- name: corpus
description: Which corpus to search
in: query
type: string
- name: embedding
description: Query vector on which to search the dataset
in: query
type: array
items:
type: number
- name: layer
description: Which layer to search the nearest for
in: query
type: number
- name: heads
description: List of heads to search for
in: query
type: array
items:
type: number
- name: k
description: How many nearest neighbors to grab
in: query
type: number
responses:
200:
description: Return related embeddings and associated metadata
/k-nearest-contexts:
get:
tags: [All]
operationId: main.nearest_context_search
summary: Search for the nearest embeddings BY SELECTED HEADS to a token sent from the frontend by layer
parameters:
- name: model
description: Which model to get information from
in: query
type: string
- name: corpus
description: Which corpus to search
in: query
type: string
- name: context
description: Query vector on which to search the dataset
in: query
type: array
items:
type: number
- name: layer
description: Which layer to search the nearest for
in: query
type: number
- name: heads
description: List of heads to search for
in: query
type: array
items:
type: number
- name: k
description: How many nearest neighbors to grab
in: query
type: number
responses:
200:
description: Return related embeddings by that head and the associated metadata
definitions:
maskPayload:
type: object
properties:
model:
type: string
description: Which model to get results from
tokens:
type: array
items:
type: string
description: Main sentence tokens to analyze
sentence:
type: string
description: The original sentence the tokens came from, for extracting metadata
mask:
type: array
items:
type: number
description: Indices of tokens to mask
layer:
type: number
description: Layer to get results for
required:
- model
- tokens
- sentence
- mask
- layer |