File size: 1,068 Bytes
91eaff6
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
#!/usr/bin/env python
# -*- coding: utf-8 -*-

"""
`replicate` demo from
<https://github.com/replicate/replicate-python#readme>
"""

import typing

import replicate  # pylint: disable=E0401


if __name__ == "__main__":
    # load `Notus` model: <https://huggingface.co/argilla/notus-7b-v1>
    model: replicate.model.Model = replicate.models.get(
        "titocosta/notus-7b-v1",
    )

    version: replicate.version.Version = model.versions.get(
        "dbcd2277b32873525e618545e13e64c3ba121b681cbd2b5f0ee7f95325e7a395",
    )

    prompt: str = """
Sentence: {}
Extract RDF predicate from the sentence in this format:
SUBJECT:<subject>
PREDICATE:<predicate>
OBJECT:<object, optional>
    """

    text: str = """
Werner Herzog is a German film director, screenwriter, author, actor, and opera director, regarded as a pioneer of New German Cinema.
    """

    output: typing.Iterator[ str ] = replicate.run(
        version,
        input = {
            "prompt": prompt.format(text.strip()).strip(),
        },
    )

    for item in output:
        print(item)