Acknowledge License and Additional Terms of Use to accept the repository

This repository is publicly accessible, but you have to accept the conditions to access its files and content.

Copyright 2025 Fujitsu Limited

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and limitations under the License.

Additional Terms of Use

In addition to the License, You shall use Fujitsu-LLM-KG-8x7B_inst-infer_v1 upon agreeing to this Terms of Use (hereinafter referred to as “TOU”). All capitalized terms used but not defined in this TOU have the meanings set forth in the License.

Article 1 (License to Use)
You must incorporate the TOU and the License into the license terms for redistribution of Fujitsu-LLM-KG-8x7B_inst-infer_v1 or Derivative Works of Fujitsu-LLM-KG-8x7B_inst-infer_v1, or into the terms of use for services using Fujitsu-LLM-KG-8x7B_inst-infer_v1 or Derivative Works. Those who violate the TOU and/or License are not allowed to use Fujitsu-LLM-KG-8x7B_inst-infer_v1.

Article 2 (Responsibility)
You shall use Fujitsu-LLM-KG-8x7B_inst-infer_v1 at Your own responsibility and discretion, and shall handle any disputes arising with third parties in relation to the use of Fujitsu-LLM-KG-8x7B_inst-infer_v1 at Your own responsibility and expense, and shall indemnify, defend and hold harmless the Licensor against all damages and losses without causing any inconvenience to the Licensor. You shall deal with any damages caused by the use of Fujitsu-LLM-KG-8x7B_inst-infer_v1 at Your own responsibility.

Article 3 (Prohibited Actions)
You shall not engage in the following actions when using Fujitsu-LLM-KG-8x7B_inst-infer_v1.
(1) Actions that will or may infringe on the intellectual property rights of the Licensor or third parties;
(2) Actions that will or may infringe on the property, privacy, or portrait rights of the Licensor or third parties;
(3) Actions that discriminate against, defame, insult, or slander the Licensor or third parties, promote discrimination against others, or damage the reputation or credibility of others;
(4) Actions that engage in unauthorized legal services and/or provide legal advice from anyone other than a qualified professional;
(5) Actions that provide financial advice from anyone other than a qualified professional;
(6) Medical actions, including providing health advice or suggesting treatment methods; and
(7) Other actions that require permissions or other forms of authorization under laws and regulations.

Article 4 (Restrictions)

  1. You acknowledge that the results of processing using Fujitsu-LLM-KG-8x7B_inst-infer_v1 (hereinafter referred to as "Processing Results") may contain falsehoods, biases, content that infringes on the rights of others, or content that does not meet the effectiveness or usefulness expected by You, and agree to use Fujitsu-LLM-KG-8x7B_inst-infer_v1 on the premise that inaccurate or inappropriate Processing Results may cause damage or infringement of rights to You or third parties and/or ethical concerns. You shall use the Processing Results after confirming their accuracy, legality, and ethical validity themselves. If the use of Fujitsu-LLM-KG-8x7B_inst-infer_v1, including the Processing Results, by You cause infringement of the rights of You or third parties, the Licensor shall not be responsible for any damages and losses, and You shall indemnify, defend and hold harmless the Licensor against all damages and losses without causing any inconvenience to the Licensor.
  2. You shall use the Processing Results in compliance with the regulations such as laws and regulations in each country and region.
  3. You shall not use the Processing Results for the actions listed in Article 3 (Prohibited Actions).

Article 5 (Ownership of Rights)
You will acquire rights newly arising from the creation of Derivative Works of Fujitsu-LLM-KG-8x7B_inst-infer_v1, but You shall use Derivative Works in accordance with the above License and TOU.

Article 6 (Export Transaction)
You shall obtain the necessary permissions yourself when exporting Fujitsu-LLM-KG-8x7B_inst-infer_v1 and the Processing Results in relation to Your use, where such export requires permissions under the Foreign Exchange and Foreign Trade Act (including related cabinet order and ministerial order) or U.S. export control laws and regulations.

Article 7 (Jurisdictional Court)
The Tokyo District Court shall have exclusive jurisdiction in the first instance over any disputes arising in relation to TOU.

Article 8 (Governing Law)
TOU shall be governed by the laws of Japan.

Article 9 (Other Provisions)
Except the terms of the License, TOU sets forth the entire agreement as to all matters concerning the use of Fujitsu-LLM-KG-8x7B_inst-infer_v1 between You and the Licensor, and matters not provided for in the TOU shall be governed by the relevant laws and regulations.

Log in or Sign Up to review the conditions and access this model content.

Fujitsu-LLM-KG-8x7B_inst-infer_v1

本モデルは、国立研究開発法人 新エネルギー・産業技術総合開発機構(NEDO)の公募「ポスト5G情報通信システム基盤強化研究開発事業/①ポスト5G情報通信システムの開発」および経済産業省が主催する「Generative AI Accelerator Challenge(GENIAC)プロジェクト」に採択された当富士通株式会社の提案事業「論理推論を可能とする大規模言語モデルの研究開発」中に開発した、ナレッジグラフの生成/推論に特化した大規模言語モデル(LLM)の1つです。

同提案事業中に開発したモデルは、以下の表に一覧しています。 各モデルの評価結果や開発内容については、富士通研究所の技術ブログに詳細がありますので是非ご覧ください。

Model Index

モデル 名称 概要
Fujitsu-LLM-KG-8x7B_cpt 共通事前学習済みLLM ナレッジグラフ対訳コーパスで継続事前学習したLLM。
Fujitsu-LLM-KG-8x7B_inst-infer_v1 ナレッジグラフ推論LLM ver.1 日本語のマルチホップQAタスクデータで指示学習したLLM。
Fujitsu-LLM-KG-8x7B_inst-infer_v2 ナレッジグラフ推論LLM ver.2 英語のマルチホップQAタスクデータで指示学習したLLM。
Fujitsu-LLM-KG-8x7B_inst-gen_ja ナレッジグラフ生成LLM(日本語版) 日本語の文書レベル関係抽出タスクデータで指示学習したLLM。
Fujitsu-LLM-KG-8x7B_inst-gen_en ナレッジグラフ生成LLM(英語版) 英語の文書レベル関係抽出タスクデータで指示学習したLLM。

Model Details

Model Performance

How to use

Preparation

必要なPythonモジュールをインストールする。

# Tested with the following versions; transformers==4.48.1, torch==2.5.1, and accelerate==1.3.0.
$ pip install transformers torch accelerate

ユーティリティを定義する。

import torch
from transformers import AutoModelForCausalLM, AutoTokenizer

class Fujitsu_LLM_KG:
    """The Fujitsu-LLM-KG-8x7B model.
    """
    def __init__(self, model_id: str, *, device_map: str = "auto") -> None:
        """Initializes the model and tokenizer.
        """
        self.model = AutoModelForCausalLM.from_pretrained(
                        model_id,
                        device_map=device_map,
                        torch_dtype=torch.bfloat16,
                        low_cpu_mem_usage=True,
                    )
        self.tokenizer = AutoTokenizer.from_pretrained(model_id, padding_side="left")
        self.tokenizer.pad_token = self.tokenizer.eos_token

    def generate(self, prompt:str, 
            *, 
            max_new_tokens: int = 2048,
            num_beams: int = 1,
        ) -> str:
        """Generate an answer.
        """
        tokenized = self.tokenizer(prompt, return_tensors="pt", padding=True)
        with torch.no_grad():
            outputs = self.model.generate(
                        tokenized["input_ids"].to("cuda"),
                        attention_mask=tokenized["attention_mask"].to("cuda"),
                        pad_token_id=self.tokenizer.eos_token_id,
                        max_new_tokens=max_new_tokens,
                        do_sample=False,
                        num_beams=num_beams,
                    )
            answer = self.tokenizer.decode(outputs[0], skip_special_tokens=True)[len(prompt):]
        return answer

def extract_turtle(text: str, *, with_rationale = False) -> str:
    """Extracts the RDF Turtle part from the output text of the Fujitsu-LLM-KG-8x7B models.
    """
    TOKENS = ["<", "rel:", "rdf:", "]"]
    if with_rationale:
        TOKENS.append("#@")
    turtle = ""
    for line in text.splitlines():
        line_ = line.strip()
        if line == "" or any(line_.startswith(c) for c in TOKENS):
            if turtle:
                turtle += "\n"
            turtle += line
    return turtle

モデルを読み込む。

kgllm = Fujitsu_LLM_KG("Fujitsu-LLM-KG/Fujitsu-LLM-KG-8x7B_inst-infer_v1")

Generates Graph Schema

(以下のタスク例は、JEMHopQAを改変したもののため、CC BY-SA 4.0ライセンスが継承されます)

タスクを指示する。

question = "長岡京に遷都される前の都の所在地は現在の何県の何市にあたるでしょうか?"

prompt_schema = f"""
[INST]
Generate "Knowledge Graph" in RDF Turtle format based on the given "Source".

## Source
```txt
{question}
```

## Strategy
Extract graph schema needed to answer the question in above "Source" as knowledge triples without omission.
[/INST]
"""

generated_schema = kgllm.generate(prompt_schema)
print(generated_schema)

結果を確認する。

## Knowledge Graph
```turtle
<#長岡京>
    rel:遷都される前の都 <#?>.

<#?>
    rel:現在の県 <#?>;
    rel:現在の市 <#?>.
```

Resolves to Knowledge Graph

(以下のタスク例は、Wikipediaを改変したもののため、CC BY-SA 3.0ライセンスが継承されます)

タスクを指示する。

prompt_kg = f"""
[INST]
Generate "Knowledge Graph" in RDF Turtle format based on the given "Source".

## Source
```txt
平安京

平安京(へいあんきょう/たいらのみやこ)または平安城(へいあんじょう)は、日本における古代最後の宮都。794年(延暦13年)から1869年(明治2年)までの日本の首都。
桓武天皇により、長岡京に代わる都として山背国(山城国)愛宕・葛野の両郡にまたがる地が選ばれ、中国の洛陽城や長安城を模して793年(延暦12年)から建設された。翌794年(延暦13年)に遷都。北部中央に宮城・平安宮(大内裏)が建設され、以降歴代の皇居が置かれた。
遷都以来、平清盛により断行された福原遷都(1180年)の期間を除いて、東京奠都まで1100年近くに亘って都として機能し、1869年(明治2年)まで続いた。今日の京都市街が形成されるに至る。
----
平城京

平城京(へいじょうきょう/へいぜいきょう/ならのみやこ)は、奈良時代の日本の首都。710年に藤原京から遷都するにあたり、唐の都長安城を模倣して大和国に建造された都城。現在の奈良県奈良市、大和郡山市に存在する。
中央北域に宮城・平城宮(大内裏)を置き、東西8坊 (約 4.3 km) の面積をもち、中央を南北に走る朱雀大路によって左京・右京に二分され、さらに南北・東西を大路・小路によって碁盤の目のように整然と区画され、全域が72坊に区画設定されていた。
大阪湾や淡路島(八島のひとつ)にも近い奈良盆地(奈良県奈良市の西部の一部、中心部及び大和郡山市北部)には、5世紀中頃にはすでに天皇陵である佐紀盾列古墳群が作られ、またのちには大神神社、7世紀には興福寺も建立されているが、京となった8世紀には、東大寺や巨大な仏像である東大寺盧舎那仏像、法華寺などが建立された。本州の政治・文化の中心地となるに至って外京(げきょう)に位置した門前町が、今に続く奈良の町を形成する中心となった。
----
長岡京

長岡京(ながおかきょう)は、山城国乙訓郡にあった奈良時代末期(または平安時代初期)の都城(現在の京都府向日市、長岡京市、京都市西京区)。宮域跡は向日市鶏冠井町(かいでちょう)に位置し、「長岡宮跡」として国の史跡に指定されている。
延暦3年(784年)11月11日、第50代桓武天皇により平城京から遷都され、延暦13年(794年)10月22日に平安京に遷都されるまで機能した。
```

## Strategy
Extract all verifiable facts in above "Source", that match the following graph schema, as knowledge triples without omission.
```turtle
{extract_turtle(generated_schema)}
```
The extracted facts are needed to answer the question "{question}".
[/INST]
"""

generated_kg = kgllm.generate(prompt_kg)
print(generated_kg)

結果を確認する。

## Knowledge Graph
```turtle
<#長岡京>
    rel:遷都される前の都 <#平城京>.

<#平城京>
    rel:現在の県 <#奈良県>;
    rel:現在の市 <#奈良市>.
```

Generate Final Answer

タスクを指示する。

prompt_answer = f"""
[INST]
Explore "Knowledge Graph" entity-to-entity then finally answer "Question".

## Knowledge Graph
```turtle
{extract_turtle(generated_kg)}
```

## Question
{question}

## Strategy
Answer briefly in one line.
[/INST]
"""

generated_answer = kgllm.generate(prompt_answer)
print(generated_answer)

結果を確認する。

## Explore Path
```path
長岡京 → rel:遷都される前の都 → 平城京
平城京 → rel:現在の県 → 奈良県
平城京 → rel:現在の市 → 奈良市
```

## Answer
```txt
奈良県奈良市
```

Training Datasets

Instruction Tuning

  • ナレッジグラフ推論用の指示学習データ ver.1
    • JEMHopQAから合成したタスクデータ

License

Fujitsu-LLM-KG-8x7B_inst-infer_v1の利用規約(Terms of Use)は、LICENSEファイルに記載しております。

Risks and Limitations

Fujitsu-LLM-KG-8x7B_inst-infer_v1を利用した処理結果には、虚偽、偏り、他者の権利を侵害する内容、利用者が期待する効果や有用性を満たさない内容が含まれる可能性があります。

Acknowledgements

本モデルの開発は、NEDOが推進する「ポスト5G情報通信システム基盤強化研究開発事業/ポスト5G情報通信システムの開発」の助成を受けたものです。

Authors

  • 富士通株式会社
Downloads last month
0
Safetensors
Model size
46.7B params
Tensor type
F32
·
Inference Providers NEW
This model is not currently available via any of the supported Inference Providers.
The model cannot be deployed to the HF Inference API: The model has no library tag.

Model tree for Fujitsu-LLM-KG/Fujitsu-LLM-KG-8x7B_inst-infer_v1

Collection including Fujitsu-LLM-KG/Fujitsu-LLM-KG-8x7B_inst-infer_v1