Skip to content
This repository has been archived by the owner on Jun 15, 2023. It is now read-only.

Commit

Permalink
done with first stetp
Browse files Browse the repository at this point in the history
  • Loading branch information
daveshap committed Jun 15, 2023
1 parent 0845e9e commit 6caab03
Show file tree
Hide file tree
Showing 41 changed files with 3,880 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
key_openai.txt
3,664 changes: 3,664 additions & 0 deletions act.txt

Large diffs are not rendered by default.

99 changes: 99 additions & 0 deletions step01_simplify.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
import os
import textwrap
from halo import Halo
import openai
from time import time, sleep



### file operations



def save_yaml(filepath, data):
with open(filepath, 'w', encoding='utf-8') as file:
yaml.dump(data, file, allow_unicode=True)



def open_yaml(filepath):
with open(filepath, 'r', encoding='utf-8') as file:
data = yaml.load(file, Loader=yaml.FullLoader)
return data



def save_file(filepath, content):
with open(filepath, 'w', encoding='utf-8') as outfile:
outfile.write(content)



def open_file(filepath):
with open(filepath, 'r', encoding='utf-8', errors='ignore') as infile:
return infile.read()




def chunk_string(s):
lines = s.split('\n')
return ['\n'.join(lines[i:i+100]) for i in range(0, len(lines), 100)]



def save_strings(strings, folder):
for i, s in enumerate(strings, 1):
filepath = os.path.join(folder, f'file{i:05}.txt')
save_file(filepath, s)


### chatbot functions



def chatbot(messages, model="gpt-4-0613", temperature=0):
#def chatbot(messages, model="gpt-3.5-turbo-0613", temperature=0):
openai.api_key = open_file('key_openai.txt')
max_retry = 7
retry = 0
while True:
try:
response = openai.ChatCompletion.create(model=model, messages=messages, temperature=temperature)
text = response['choices'][0]['message']['content']
return text, response['usage']['total_tokens']
except Exception as oops:
print(f'\n\nError communicating with OpenAI: "{oops}"')
if 'maximum context length' in str(oops):
a = messages.pop(1)
print('\n\n DEBUG: Trimming oldest message')
continue
retry += 1
if retry >= max_retry:
print(f"\n\nExiting due to excessive errors in API: {oops}")
exit(1)
print(f'\n\nRetrying in {2 ** (retry - 1) * 5} seconds...')
sleep(2 ** (retry - 1) * 5)



if __name__ == '__main__':
act = open_file('act.txt')
system = open_file('system_summarize.txt')
chunks = chunk_string(act)
summaries = list()
for chunk in chunks:
messages = [{'role': 'user', 'content': chunk}, {'role': 'system', 'content': system}]

spinner = Halo(text='Summarizing next chunk...', spinner='dots')
spinner.start()

response, tokens = chatbot(messages)

spinner.stop()

formatted_lines = [textwrap.fill(line, width=120, initial_indent=' ', subsequent_indent=' ') for line in response.split('\n')]
formatted_text = '\n'.join(formatted_lines)
print('\n\n\n\n', formatted_text)
summaries.append(response)
save_strings(summaries, 'summaries')
1 change: 1 addition & 0 deletions summaries/file00001.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
The European Commission proposes a regulation for harmonised rules on Artificial Intelligence (AI), aiming to balance its socio-economic benefits with potential risks. The proposal seeks to ensure AI systems are safe, respect fundamental rights, provide legal certainty for investment and innovation, enhance governance, and prevent market fragmentation. It prohibits certain harmful AI practices, imposes restrictions on remote biometric identification systems, and defines "high-risk" AI systems that must comply with mandatory requirements. The proposal also establishes a governance system at Member State level and a European Artificial Intelligence Board at Union level. It supports innovation through AI regulatory sandboxes and measures to reduce regulatory burden on SMEs and start-ups. The proposal aligns with existing EU legislation and policies, including data protection, consumer protection, non-discrimination, and gender equality.
1 change: 1 addition & 0 deletions summaries/file00002.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
This proposal outlines regulations for Artificial Intelligence (AI) systems in the EU. It is based on extensive stakeholder consultation and impact assessments. The proposal adopts a risk-based approach, categorizing AI systems into three risk levels: unacceptable, high, and low or minimal. Certain AI practices are prohibited due to their potential to violate fundamental rights. High-risk AI systems are subject to specific requirements and obligations, including data handling, transparency, human oversight, and robustness. The proposal also includes measures to support innovation and compliance for small-scale users and providers. The proposal aims to increase trust in AI, provide legal certainty, and prevent market fragmentation. It also includes provisions for monitoring and evaluation, with a review scheduled five years after implementation.
1 change: 1 addition & 0 deletions summaries/file00003.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
This legislation outlines the European Union's rules for high-risk artificial intelligence (AI) systems. It classifies high-risk AI systems based on their intended purpose and usage, and requires them to comply with mandatory requirements and an ex-ante conformity assessment. The legislation also sets out legal requirements for data governance, transparency, human oversight, and system robustness. It places obligations on providers of high-risk AI systems and other participants in the AI value chain. The legislation also establishes a framework for regulatory sandboxes to test innovative technologies and includes measures to reduce the regulatory burden on SMEs and start-ups. It sets up governance systems at Union and national level, and requires providers of AI systems to register their systems in an EU database. The legislation also includes transparency obligations for certain AI systems and creates a framework for voluntary codes of conduct.
1 change: 1 addition & 0 deletions summaries/file00004.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
This legislation proposes a risk-based approach to regulate artificial intelligence (AI) systems, focusing on high-risk AI systems that could potentially harm human dignity, freedom, democracy, equality, and fundamental rights. It prohibits AI practices that manipulate human behavior, exploit vulnerabilities, or enable social scoring by public authorities. It also restricts the use of AI for real-time remote biometric identification in public spaces, except in specific situations related to law enforcement. The legislation mandates that high-risk AI systems comply with requirements related to data quality, technical documentation, transparency, human oversight, and robustness. It also outlines responsibilities for providers, users, and third parties involved in the AI value chain. The legislation emphasizes the role of standardization and conformity assessment in ensuring the trustworthiness of high-risk AI systems.
1 change: 1 addition & 0 deletions summaries/file00005.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
This regulation outlines rules for the use and development of artificial intelligence (AI) systems in the EU. It limits third-party conformity assessment for high-risk AI systems, with exceptions for remote biometric identification systems. Notified bodies should be designated for third-party conformity assessment. AI systems should undergo new conformity assessments for significant modifications or changes in purpose. High-risk AI systems should bear the CE marking for conformity and free movement within the internal market. Member States can authorize non-conformity assessed AI systems for public security or protection of life and health. Providers of high-risk AI systems should register their systems in an EU database. AI systems interacting with natural persons or generating content should have specific transparency obligations. Regulatory sandboxes should be established for testing innovative AI systems. The regulation also establishes a European Artificial Intelligence Board for advisory tasks. Member States should designate national competent authorities for supervising the application and implementation of this regulation. Providers should have a post-market monitoring system in place. The regulation also encourages the development of non-high-risk AI systems in accordance with the requirements of this regulation. The regulation applies to providers and users of AI systems in the Union and those located in a third country where the output is used in the Union.
1 change: 1 addition & 0 deletions summaries/file00006.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
This EU regulation does not apply to AI systems used for military purposes, by third-country public authorities, or in international law enforcement agreements. It defines terms related to AI systems, including 'provider', 'user', 'importer', 'distributor', 'operator', and 'intended purpose'. It also outlines the roles of 'authorized representatives' and 'small-scale providers'. The regulation further defines terms related to the market placement, service provision, and modification of AI systems. It also covers conformity assessment, post-market monitoring, and market surveillance authority. The regulation provides definitions for various types of data used in AI systems, including 'training data', 'validation data', 'testing data', and 'input data'. It also defines terms related to biometric data and its use in AI systems. Lastly, it defines terms related to law enforcement authorities and their activities.
1 change: 1 addition & 0 deletions summaries/file00007.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
This legislation defines the roles of national supervisory and competent authorities in implementing and applying AI regulations. It prohibits certain AI practices, such as using subliminal techniques or exploiting vulnerabilities to harm individuals, and using AI systems to evaluate or classify individuals' trustworthiness based on their social behavior. The use of real-time remote biometric identification systems in public spaces for law enforcement is also regulated, requiring prior authorization and compliance with necessary safeguards. The legislation classifies certain AI systems as high-risk, including those used as safety components of products covered by Union harmonisation legislation, and empowers the Commission to update the list of high-risk AI systems.
5 changes: 5 additions & 0 deletions summaries/file00008.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
This legislation mandates that high-risk AI systems must comply with established requirements, considering their intended purpose and risk management system. A risk management system must be implemented, involving continuous analysis and evaluation of known and foreseeable risks, adoption of risk management measures, and communication of residual risks to the user. The AI systems must be tested for risk management measures and compliance with requirements.

The legislation also requires the use of quality training, validation, and testing data sets for developing high-risk AI systems. These data sets must be relevant, representative, free of errors, and complete. They should also consider specific geographical, behavioural, or functional settings.

The legislation mandates the creation of technical documentation before the AI system is placed on the market or put into service, which should demonstrate compliance with requirements. The AI systems should also have capabilities for automatic recording of events (logs) while operating.
5 changes: 5 additions & 0 deletions summaries/file00009.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
High-risk AI systems must have logging capabilities for traceability and monitoring, recording usage periods, reference databases, input data, and identification of individuals verifying results. These systems must be transparent, with clear instructions and information about the provider, system's purpose, performance, limitations, changes, human oversight measures, and expected lifetime.

Human oversight is required to minimize risks, with measures built into the system or implemented by the user. The overseers must understand the system's capacities and limitations, be aware of automation bias, interpret the system's output, have the ability to override the system, and intervene or stop the system's operation.

High-risk AI systems must achieve appropriate levels of accuracy, robustness, and cybersecurity, and be resilient against errors, faults, inconsistencies, and unauthorized third-party attempts to alter their use or performance. Providers of these systems must ensure compliance with these requirements.
5 changes: 5 additions & 0 deletions summaries/file00010.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Providers of high-risk AI systems must have a quality management system that complies with Article 17, create technical documentation, keep automatically generated logs, ensure the system undergoes a conformity assessment before being put on the market, comply with registration obligations, take corrective actions if the system doesn't comply with requirements, inform national authorities of non-compliance and corrective actions, affix the CE marking to indicate conformity, and demonstrate conformity upon request.

Article 17 outlines the requirements for the quality management system, including strategies for regulatory compliance, design and development procedures, testing and validation procedures, technical specifications, data management systems, risk management, post-market monitoring, incident reporting, communication handling, record keeping, resource management, and an accountability framework.

Article 18 requires providers to draw up technical documentation. Article 19 mandates a conformity assessment before the system is put on the market. Article 20 requires providers to keep automatically generated logs. Article 21 requires providers to take corrective actions if the system doesn't comply with the regulation. Article 22 mandates providers to inform national authorities if the system presents a risk. Article 23 requires providers to cooperate with competent authorities. Article 24 outlines the obligations of product manufacturers. Article 25 requires providers outside the Union to appoint an authorised representative in the Union.
1 change: 1 addition & 0 deletions summaries/file00011.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
This legislation outlines the obligations of providers, importers, distributors, users, and other third parties of high-risk AI systems. Providers must keep a copy of the EU declaration of conformity and technical documentation, provide necessary information to demonstrate conformity, and cooperate with national authorities. Importers must ensure the AI system has undergone the appropriate conformity assessment procedure, bears the required conformity marking, and is accompanied by the required documentation. Distributors must verify the AI system's conformity and ensure storage or transport conditions do not jeopardize its compliance. Users must use the AI system according to instructions, monitor its operation, and keep logs. Any distributor, importer, user, or third party that modifies a high-risk AI system or places it on the market under their name is considered a provider. The legislation also outlines the responsibilities of notifying authorities and the application process for a conformity assessment body for notification.
1 change: 1 addition & 0 deletions summaries/file00012.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
This legislation outlines the procedures for notifying authorities about conformity assessment bodies, which must meet the requirements in Article 33. These bodies assess the conformity of high-risk AI systems. The bodies must be independent, impartial, and maintain confidentiality. They must have sufficient resources, insurance, and competence to carry out their tasks. They must also participate in coordination activities and standardisation organisations. If a body subcontracts tasks, it must ensure the subcontractor meets the same requirements. The Commission assigns identification numbers to these bodies and maintains a public list. If a body no longer meets the requirements or fails its obligations, the notifying authority must investigate and may restrict, suspend or withdraw the notification. The Commission can also investigate and request corrective measures. Conformity assessment bodies in third countries may be authorised to carry out these activities. High-risk AI systems that conform to harmonised standards are presumed to meet the requirements.
15 changes: 15 additions & 0 deletions summaries/file00013.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
Article 41 allows the Commission to adopt common specifications for AI systems if harmonised standards are insufficient or non-existent. The Commission must consult relevant bodies or expert groups when preparing these specifications. AI systems that comply with these specifications are presumed to meet the requirements of Chapter 2. Providers not complying with these specifications must justify their technical solutions.

Article 42 presumes high-risk AI systems to be in compliance with certain requirements if they have been trained and tested on specific data or certified under a cybersecurity scheme.

Article 43 outlines the conformity assessment procedures for high-risk AI systems. Providers must follow specific procedures based on whether they have applied harmonised standards or common specifications. High-risk AI systems must undergo a new conformity assessment if substantially modified.

Article 44 states that certificates issued by notified bodies are valid for up to five years and can be extended. If an AI system no longer meets requirements, the certificate can be suspended or withdrawn.

Article 45 ensures an appeal procedure against decisions of notified bodies.

Article 46 requires notified bodies to inform the notifying authority of any changes to certificates or approvals and share information with other notified bodies.

Article 47 allows market surveillance authorities to authorise the use of specific high-risk AI systems for exceptional reasons, subject to certain conditions and procedures.

Article 48 is not provided.
11 changes: 11 additions & 0 deletions summaries/file00014.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
AI system providers must create an EU declaration of conformity for each AI system, kept for 10 years and provided to authorities upon request. The declaration confirms the AI system meets requirements outlined in Chapter 2 and contains information from Annex V, translated into required languages. If multiple legislations apply, a single declaration is drawn up. The provider assumes responsibility for compliance. The Commission can update the declaration content as needed.

High-risk AI systems must have a visible CE marking of conformity. If not possible, it's affixed to packaging or documentation. The marking follows principles in Regulation (EC) No 765/2008 and includes the identification number of the notified body responsible for conformity assessment.

Providers must keep technical documentation, quality management system documentation, approved changes, decisions, and other documents issued by notified bodies, and the EU declaration of conformity for 10 years. High-risk AI systems must be registered in the EU database before being placed on the market.

AI systems interacting with humans must inform them they're interacting with an AI, unless it's obvious or the system is used for law enforcement. Users of emotion recognition or biometric categorisation systems must inform exposed individuals. AI systems generating or manipulating content resembling real entities must disclose the content is artificially generated.

AI regulatory sandboxes provide a controlled environment for AI system development, testing, and validation under supervision of competent authorities. Participants remain liable for any harm caused during sandbox experimentation. Sandbox activities are coordinated within the European Artificial Intelligence Board, with annual reports submitted to the Board and the Commission. Implementing acts outline the operation of the sandboxes.

In the sandbox, personal data collected for other purposes can be processed for developing and testing AI systems under certain conditions, including substantial public interest, necessity, effective monitoring mechanisms, data isolation, no data transmission to other parties, and no measures or decisions affecting data subjects.
Loading

0 comments on commit 6caab03

Please sign in to comment.