Spaces:
Sleeping
Sleeping
Create swagger.yaml
Browse files- server/swagger.yaml +99 -0
server/swagger.yaml
ADDED
@@ -0,0 +1,99 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# see also: https://github.com/hjacobs/connexion-example
|
2 |
+
|
3 |
+
swagger: '2.0'
|
4 |
+
info:
|
5 |
+
title: BERT-viz API
|
6 |
+
version: "0.0.1"
|
7 |
+
consumes:
|
8 |
+
- application/json
|
9 |
+
produces:
|
10 |
+
- application/json
|
11 |
+
basePath: /api
|
12 |
+
|
13 |
+
# ===============================================================================
|
14 |
+
## DEFINE API ##
|
15 |
+
# ===============================================================================
|
16 |
+
paths:
|
17 |
+
|
18 |
+
/get-model-details:
|
19 |
+
get:
|
20 |
+
tags: [All]
|
21 |
+
operationId: main.get_model_details
|
22 |
+
summary: Get necessary information about the model, such as number of layers and heads
|
23 |
+
parameters:
|
24 |
+
- name: model
|
25 |
+
description: Short string representing pretrained model, such as 'bert-base-uncased'
|
26 |
+
in: query
|
27 |
+
type: string
|
28 |
+
responses:
|
29 |
+
200:
|
30 |
+
description: Returns information about the model
|
31 |
+
|
32 |
+
/attend+meta:
|
33 |
+
get:
|
34 |
+
tags: [All]
|
35 |
+
operationId: main.get_attentions_and_preds
|
36 |
+
summary: Get the attention information, BERT Embeddings, and spacy meta info for an input sentence
|
37 |
+
parameters:
|
38 |
+
- name: model
|
39 |
+
description: Which pretrained transformer information is requested from
|
40 |
+
in: query
|
41 |
+
type: string
|
42 |
+
- name: sentence
|
43 |
+
description: Sentence to analyze
|
44 |
+
in: query
|
45 |
+
type: string
|
46 |
+
- name: layer
|
47 |
+
description: Layer to get attentions at
|
48 |
+
in: query
|
49 |
+
type: number
|
50 |
+
responses:
|
51 |
+
200:
|
52 |
+
description: Returns attentions, embeddings, and metadata
|
53 |
+
|
54 |
+
/update-mask:
|
55 |
+
post:
|
56 |
+
tags: [All]
|
57 |
+
operationId: main.update_masked_attention
|
58 |
+
summary: Get the masked attention information of tokens given indices to mask
|
59 |
+
parameters:
|
60 |
+
- name: payload
|
61 |
+
description: Main contents
|
62 |
+
in: body
|
63 |
+
schema:
|
64 |
+
$ref: '#/definitions/maskPayload'
|
65 |
+
responses:
|
66 |
+
200:
|
67 |
+
description: Update BERT's masked behavior for passed tokens
|
68 |
+
|
69 |
+
|
70 |
+
definitions:
|
71 |
+
maskPayload:
|
72 |
+
type: object
|
73 |
+
properties:
|
74 |
+
model:
|
75 |
+
type: string
|
76 |
+
description: Which model to get results from
|
77 |
+
tokens:
|
78 |
+
type: array
|
79 |
+
items:
|
80 |
+
type: string
|
81 |
+
description: Main sentence tokens to analyze
|
82 |
+
sentence:
|
83 |
+
type: string
|
84 |
+
description: The original sentence the tokens came from, for extracting metadata
|
85 |
+
mask:
|
86 |
+
type: array
|
87 |
+
items:
|
88 |
+
type: number
|
89 |
+
description: Indices of tokens to mask
|
90 |
+
layer:
|
91 |
+
type: number
|
92 |
+
description: Layer to get results for
|
93 |
+
|
94 |
+
required:
|
95 |
+
- model
|
96 |
+
- tokens
|
97 |
+
- sentence
|
98 |
+
- mask
|
99 |
+
- layer
|