Пример #1
0
from nubia import Nubia
import gradio

nubia = Nubia()


def predict(inp_1, inp_2):
    features = nubia.score(inp_1, inp_2, get_features=True)
    labels = {k: v for k, v in features["features"].items()}
    labels["Pct logical contradiction"] = labels["contradiction"]
    del labels["contradiction"]
    labels["Pct logical agreeement"] = labels["logical_agreement"]
    del labels["logical_agreement"]
    labels["Pct irrelevancy (or new information)"] = labels["irrelevancy"]
    del labels["irrelevancy"]
    labels["Semantic Similarity (out of 5.0)"] = labels["semantic_relation"]
    del labels["semantic_relation"]
    del labels["grammar_hyp"]
    del labels["grammar_ref"]
    return {"nubia_score": features["nubia_score"]}, labels


title = "NUBIA: A Neural Metric for Text Generation"
description = "NUBIA stands for 'NeUral Based Interchangeability Assessor'. \n NUBIA gives a score on a scale of 0 to 1 reflecting how much it thinks the candidate text is interchangeable with the reference text. It also shows its rationale for the score obtained by comparing the candidate and reference text."
inputs = [
    gradio.inputs.Textbox(lines=5, label="Reference Text"),
    gradio.inputs.Textbox(lines=5, label="Candidate Text")
]
outputs = [
    gradio.outputs.Label(label="Interchangeability Score"),
    gradio.outputs.JSON(label="Neural Features (Explanation)")
Пример #2
0
def main():
    plugin = LogDevicePlugin()
    shell = Nubia(name="ldshell", plugin=plugin, command_pkgs=commands)
    sys.exit(shell.run())
Пример #3
0
import sys

import commands
from nubia import Nubia, Options
from extra.tfx_plugin import TFXPlugin

if __name__ == "__main__":
    plugin = TFXPlugin()
    shell = Nubia(
        name="tfx_template",
        command_pkgs=commands,
        plugin=plugin,
        options=Options(persistent_history=False,
                        auto_execute_single_suggestions=False),
    )
    sys.exit(shell.run())
Пример #4
0
def cli_main():
    plugin = NubiaSuzieqPlugin()
    shell = Nubia(name="suzieq",
                  plugin=plugin,
                  options=Options(persistent_history=True))
    sys.exit(shell.run())
Пример #5
0
def main():
    plugin = LogDevicePlugin()
    shell = Nubia(name="ldshell", plugin=plugin)
    sys.exit(shell.run())